公司采用ssm框架 ,工作。然后最近感冒了状态不太好。写完一个功能之后 准备启动tomcat之后进去网页测试
启动时候 报了这个错误
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.tgb.service.deptDuty.DeptDutyService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: [email protected](mappedName=, shareable=true, description=, name=, type=class java.lang.Object, authenticationType=CONTAINER, lookup=)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1100)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:855)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:441)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:419)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:544)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:150)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:304)
… 26 more
然后 发现 错误是因为没有这个合格的bean类型名字。
仔细思考之后 才发现原来错误出在下面。
public class DeptDutyServiceImpl implements DeptDutyService{
————————————————————————————————————————————————————————————————————————————–
@Service
@Transactional //此处不再进行创建SqlSession和提交事务,都已交由spring去管理了。
public class DeptDutyServiceImpl implements DeptDutyService{
加入上面的注解之后 再次启动tomcat错误消失。以此纪念。本人菜鸟有不足之处。请各位大神支出。
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/13154.html