笔者技术比较low,属于学习小白,所以不要和笔者深究springboot,springMVC等等,笔者这里实在是是有TestNG框架+spring时,自己想要用@component 和 @resource 引入方法调用时,提示报错后而去研究的,下面我说一下错误
自己在封装接口时,参考了以前的框架,应用的@Component 在调用时引用@Resource,运行时报错,贴一下代码
封装:
引用:
运行时报错:
报错:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXXXXXX': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'XXX.utils.VehicleCMSToolsUtil' 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=)}
请教了研发和百度,也就是我这没有注入spring容器无法管理,所以需要一个即可