No matching bean of type … found for dependency

后端 未结 8 769
孤城傲影
孤城傲影 2020-12-04 14:05

after some days of trying and waitin\' for answers on the springsource forums I\'ll try it here. Running my application results in these exception:

org.sprin         


        
相关标签:
8条回答
  • 2020-12-04 14:34

    In my case it was the wrong dependecy for CrudRepository. My IDE added also follwing:

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-commons</artifactId>
            <version>1.11.2.RELEASE</version>
        </dependency>
    

    But I just needed:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>RELEASE</version>
        </dependency>
    

    I removed the first one and everything was fine.

    0 讨论(0)
  • 2020-12-04 14:37

    I had the same issue but in my case, implemented class was accidently become 'abstract' as a result autowiring was failing.

    0 讨论(0)
  • 2020-12-04 14:46

    Add this to you applicationContext:

     <bean id="userService" class="com.example.my.services.user.UserServiceImpl ">
    
    0 讨论(0)
  • 2020-12-04 14:54

    IF this is only occurring on deployments, be sure that you have the dependency of the package you are referencing in the .war. For instance, this was working locally on my machine, with debug configurations working fine, but after deploying to Amazon's Elastic Beanstalk , I received this error and noticed one of the dependencies was not bundled in the .war package.

    0 讨论(0)
  • 2020-12-04 14:55

    Multiple things can cause this, I didn't bother to check your entire repository, so I'm going out on a limb here.

    First off, you could be missing an annotation (@Service or @Component) from the implementation of com.example.my.services.user.UserService, if you're using annotations for configuration. If you're using (only) xml, you're probably missing the <bean> -definition for the UserService-implementation.

    If you're using annotations and the implementation is annotated correctly, check that the package where the implementation is located in is scanned (check your <context:component-scan base-package= -value).

    0 讨论(0)
  • 2020-12-04 14:55

    Add annotation @Repository to the head of userDao Class.If userDao is a interface,add this annotation to the implements of the interface.

    0 讨论(0)
提交回复
热议问题