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里运行就会报上面的错误。
展开
 我来答
圯羌嫩壮褭缻睹B5
2017-03-19 · 超过27用户采纳过TA的回答
知道答主
回答量:42
采纳率:0%
帮助的人:29.1万
展开全部
提示的是注入不上,那么从前往后推,首先注入的前提是将对象交予tomcat,由tomcat生成;既然你win7下可以执行,表明名称没得问题,而注解的话,spring的注解应该没有问题,而Resource是javaee的,这里值得注意一下,你看看有没有将tomcat的库加进来,没有的话右键项目——>Properties——>选择Targeted Runtimes——>把tomcat勾上——>OK;
如果选择了的话,那么讲道理将对象放入容器,而自动注入也很完美。这时你可以检查一下你Tomcat的端口是不是被占了,不然怎么会在不同系统运行不一样呢?
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式