开发者社区> 问答> 正文

springmvc JUnit调试报错?报错

这项目就一个demo ,我调试不出来。。花钱学技术

tomcat可以正常启动注解,无报错,就junit调试报错:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.test.main.Test': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.test.hello.service.UserService com.test.main.Test.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.test.hello.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)}
at


项目架构为:springmvc+maven 包下,可以下载。帮忙调试一下:

junit位置:

com.test.main


结贴。。。。已经解决,必须clean ,然后maven test


展开
收起
爱吃鱼的程序员 2020-06-08 17:34:12 431 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    需要把spring-main.xml也引入进去

    @ContextConfiguration ( locations ={ "classpath*:spring-mybatis.xml", "classpath*:spring-main.xml"

    回复 @风翔飞:谢谢了,感谢回复 @开源oschina:心意领了,保持学习就是最好的回报,我也不是为了钱才答题的,也算是一种自我学习和提高回复 @风翔飞:必须给--oschina什么重要,信用。。。私给我就行了。。。回复 @开源oschina:不用了,设置最佳答案给我攒点积分就成回复 @风翔飞:我找到问题了。不是你们的问题。是eclipse的问题,必须clean。在maventest才能加载成功,已经在另外一个技术手里实现了。。。感谢你,吧你支付宝给我。--少量给你吧,当新年祝福吧。谢谢了支付宝付款
    2020-06-08 17:34:29
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载