No qualifying bean of type 'org.apache.velocity.app.VelocityEngine
2017-08-25 17:53
1136 查看
1)程序
@Autowiredprivate VelocityEngine velocityEngine;2)异常如下
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.boot.test.ApplicationTests': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.velocity.app.VelocityEngine' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(mappedName=, shareable=true, description=, name=, type=class org.apache.velocity.app.VelocityEngine, authenticationType=CONTAINER, lookup=)}at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:321)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:386)at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:44)at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)at org.junit.runners.ParentRunner.run(ParentRunner.java:363)at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.velocity.app.VelocityEngine' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(mappedName=, shareable=true, description=, name=, type=class org.apache.velocity.app.VelocityEngine, authenticationType=CONTAINER, lookup=)}at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493)at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:518)at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496)at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:627)at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169)at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:318)... 27 more3)原因,找不到
org.apache.velocity.app.VelocityEngine的控件类,及没有配置试题Bean3)解决方案 实现VelocityEngine的子类,配置成Bean,代码如下
import org.apache.velocity.app.VelocityEngine;import org.springframework.stereotype.Component;@Componentpublic class VelocityEngineBean extends VelocityEngine {}
相关文章推荐
- No qualifying bean of type 'org.apache.catalina.User' available
- No qualifying bean of type [org.apache.solr.client.solrj.SolrServer] found for dependency: expected
- Noqualifying bean of type [org.apache.solr.client.solrj.SolrServer] is defined:expected single match
- Spring 定时器 No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined
- Spring No qualifying bean of type [org.springframework.jdbc.core.JdbcTemplate] found for dependency
- Spring Task Scheduler - No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined
- No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined
- No qualifying bean of type [com.hz.app.mgmt.system.mgr.SysComBaseSettingMgr] is defined
- Spring 定时器 No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined(转)
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.oskyhang.gbd.service.UserService] found for dependency: expected at least 1 bean which qualifies as aut
- No qualifying bean of type [org.springframework.data.mongodb.core.MongoTemplate]
- shiro错误 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
- spring-session整合redis集群的时候,No qualifying bean of type [org.springframework.session.SessionRepository
- 解决:No qualifying bean of type [org.springframework.jdbc.core.JdbcTemplate] found for dependency
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.wan
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.cui
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.wei
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [cn.itca
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
- Spring 定时器 No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined