一:报错信息
org.springframework.beans.factory.BeanCreationException: Error creating bean with name XXXXXX: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.thymeleaf.spring4.SpringTemplateEngine' 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=)}
二:报错原因
1.可能是spring配置文件中没有配置需要注入的Bean或配置的BeanID和需要注入的@Resource(name="XXX")BeanID不一致
2.可能是classpath下target/test-classes路径下没有spring配置文件
三:解决方案
1.仔细核对spring配置文件的Bean和你需要注入的那个Bean是否一致或去掉@Resource(name="XXX")中的name属性
2.将配置文件copy到target/test-classes路径下即可