在使用 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"/>
对此有什么想法吗?
My file velocity-engine-core-2.0.jar
仅包含以下内容.runtime
子包:
defaults, directive, parser, resource, visitor
but no log
.
UPDATESpring Velocity Engine bean 声明中的以下 overrideLogging = FALSE 解决了该问题。But why?
<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 https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/ui/velocity/VelocityEngineFactory.html但不确定发生了什么。