spring整合mybatis时使用@Resource注解提示以下错误,该怎么解决?
org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'sys...
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'system.UserServiceTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.tjmj.test.service.UserService system.UserServiceTest.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.tjmj.test.service.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.tjmj.test.service.UserService system.UserServiceTest.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.tjmj.test.service.UserService] found for dependency: expected at
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.tjmj.test.service.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
项目在win7下运行没有任何错误,但是在win10里运行就会报上面的错误。 展开
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.tjmj.test.service.UserService system.UserServiceTest.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.tjmj.test.service.UserService] found for dependency: expected at
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.tjmj.test.service.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
项目在win7下运行没有任何错误,但是在win10里运行就会报上面的错误。 展开
1个回答
展开全部
提示的是注入不上,那么从前往后推,首先注入的前提是将对象交予tomcat,由tomcat生成;既然你win7下可以执行,表明名称没得问题,而注解的话,spring的注解应该没有问题,而Resource是javaee的,这里值得注意一下,你看看有没有将tomcat的库加进来,没有的话右键项目——>Properties——>选择Targeted Runtimes——>把tomcat勾上——>OK;
如果选择了的话,那么讲道理将对象放入容器,而自动注入也很完美。这时你可以检查一下你Tomcat的端口是不是被占了,不然怎么会在不同系统运行不一样呢?
如果选择了的话,那么讲道理将对象放入容器,而自动注入也很完美。这时你可以检查一下你Tomcat的端口是不是被占了,不然怎么会在不同系统运行不一样呢?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询