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;```