在 Spring 4.3.9下升级 Velocity 1.7.x to Velocity 2.0.x 出现的问题

1: Spring 的  spring-context-support 报错 java.lang.NoClassDefFoundError: org/apache/velocity/runtime/log/CommonsLogLogChute

等待 Spring 升级支持 Velocity 2.0.x 或自己改 Spring 的源码

velocity整个初始化日志过程:

    1. new RuntimeInstance(),属性Log log = new Log(), 默认创建一个HoldingLogChute()做为LogChute,(该LogChute临时记录日志到内存对象上)
    2. RuntimeInstance.init() 进行velocity系统初始化
    3. 顺序调用initializeProperties(), 读取velocity.properties默认配置,合并自定义的properties。
    4. 顺序调用initializeLog() ,调用LogManager.updateLog(),进行Log初始化
    5. LogManager.createLogChute()会首先读取runtime.log.logsystem配置,看看是否有存在自定义的LogChute实例对象,如果有则直接使用,并返回
    6. 在没有对应的LogChute实例对象配置,继续读取runtime.log.logsystem.class,看看似乎否有logsystem的配置,就是前面类图中的一对LogChute,LogSystem的实现类。
      Velocity.properties代码 
      1. runtime.log.logsystem.class = org.apache.velocity.runtime.log.AvalonLogChute,org.apache.velocity.runtime.log.Log4JLogChute,org.apache.velocity.runtime.log.CommonsLogLogChute,org.apache.velocity.runtime.log.ServletLogChute,org.apache.velocity.runtime.log.JdkLogChute  
        
       按照顺序,逐一加载LogChute实现类,如果class装载成功,则进行初始化,并返回
    7. LogManager,针对createLogChute,将系统初始时HoldingLogChute记录的内容,输出到新的LogChute上,最后完成了log的初始化

   可以参考:http://agapple.iteye.com/blog/815872

2:更改 Velocity.properties

runtime.conversion.handler = none
space.gobbling = bc

以上是目前发现的问题





原文地址:https://www.cnblogs.com/interdrp/p/7427504.html