Python 官方文档:入门教程 => 点击学习
目录spring注解方式无法扫描Service注解场景描述spring配置不扫描service层的原因Spring注解方式无法扫描Service注解 场景描述 系统启动没有任何错误,
系统启动没有任何错误,但是单独访问controller就会报错,原因是做了service注入。贴两张图吧
我将contoller给springmvc进行扫描,然后其余所有交给spring扫描
然后发现service层的EmployeeService并没有扫描到出现以下问题
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘springmvc.crud.service.EmployeeService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
… 39 more
最终发现原因是spring配置文件里面context:exclude-filter是不要加use-default-filters的,而context:include-filter是需要加的
找了好久问题!!!
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: Spring注解方式无法扫描Service注解的解决
本文链接: https://www.lsjlt.com/news/137608.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0