今天上班运行Tomcat报org.springframework.beans.factory.BeanCreationException:

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/weixin_42571004/article/details/93167555

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘manageCaseHistoryController’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.naturent.medical.entity.CaseHistoryAssist’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}

最后发现是使用 @Resource注入错误,参考https://blog.csdn.net/butterfly_resting/article/details/80044863
找到原因。受配置xml文件管理的ban是不能使用注解注入的,也不需要,直接声明使用就可以了,比如实体类跟Mapper类是在配置文件中注入好了。
修改前实体类(问题在这里不能拿使用注解注入,手贱)

@RequestMapping("/maseHistory")
public class ManageCaseHistoryController {
	@Resource 
	private CaseHistoryAssist caseHistoryAssist;   //实体类(问题在这里不能拿使用注解注入,手贱)
	@Resource
	private ManageCaseHistoryServiceImpl service;```

修改后

@RequestMapping("/manageCaseHistory")
public class ManageCaseHistoryController {
	//去掉自动注入注解运行成功
	private CaseHistoryAssist caseHistoryAssist;
	@Resource
	private ManageCaseHistoryServiceImpl service;```

猜你喜欢

转载自blog.csdn.net/weixin_42571004/article/details/93167555