【发布时间】:2018-02-17 12:03:58
【问题描述】:
在使用 Velocity 2.0 启动我的 Web 应用程序时,我收到以下错误:
Caused by: java.lang.NoClassDefFoundError:
org/apache/velocity/runtime/log/CommonsLogLogChute
at org.springframework.ui.velocity.VelocityEngineFactory.createVelocityEngine(VelocityEngineFactory.java:240)
at org.springframework.ui.velocity.VelocityEngineFactoryBean.afterPropertiesSet(VelocityEngineFactoryBean.java:60)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 34 more
所有依赖项都已满足。我们正在使用
- slf4j-api-1.7.25.jar
- slf4j-simple-1.7.25.jar
- commons-lang3-3.5.jar
- commons-io-2.5.jar
- commons-logging-1.2.jar(是的,我们有 Commons-Logging)
在 applicationContext.xml 中,velocityEngine bean 定义如下
<bean id="velocityEngine"
class="org.springframework.ui.velocity.VelocityEngineFactoryBean"/>
对此有什么想法吗?
我的文件velocity-engine-core-2.0.jar 仅包含以下.runtime 子包:
defaults, directive, parser, resource, visitor
但没有log。
更新 Spring Velocity Engine bean 声明中的以下 overrideLogging = FALSE 解决了该问题。 但是为什么?
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="overrideLogging" value="false" />
</bean>
我只是按照提示 https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/ui/velocity/VelocityEngineFactory.html 但不确定发生了什么。
【问题讨论】: