Could not autowire field in spring. why?

后端 未结 8 1792
长情又很酷
长情又很酷 2020-12-08 20:09

I keep getting this error, and can\'t figure out why.. yes I know there many people had similar issues, but reading the answers they got, does not solve my problem.

相关标签:
8条回答
  • 2020-12-08 20:51

    I had exactly the same problem try to put the two classes in the same package and add line in the pom.xml

    <dependency> 
                <groupId> org.springframework.boot </groupId> 
                <artifactId> spring-boot-starter-web </artifactId> 
                <version> 1.2.0.RELEASE </version> 
    </dependency>
    
    0 讨论(0)
  • 2020-12-08 21:06

    I was getting this same error and searching for it led me here. My fix appeared to be simply to add @Component annotation to the implementation of the abstract service.

    In this case, that would look like:

    import org.springframework.stereotype.Component;
    
    ...
    
    @Component
    public class ContactServiceImpl implements ContactService {
    
    0 讨论(0)
提交回复
热议问题