SimpleLogger(SLF4j)速度配置错误

问题描述 投票:0回答:1

我在Spring中为速度配置一些记录器时遇到一些困难。我正在使用Velocity 2.1,Spring 5.2.2和SLF4J 2.0.0

org.slf4j.simple.SimpleLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.

我正在尝试配置一些废弃的旧Spring类,以构建要在我的应用程序中使用的JAR(它们的新版本)。

velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, (new SimpleLoggerFactory()).getLogger("SpringVelocityConfiguration"));

这就是我的做法。但是我一直在例外。

引发异常的行来自org.apache.velocity.runtime.RuntimeInstance

 if (Logger.class.isAssignableFrom(o.getClass()))

根据我从API文档中看到的内容,SimpleLogger是Logger的子类。所以应该算是吧?

根据要求添加依赖关系树:

[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) @ spring-velocity-support ---
[INFO] com.gtt.palabs:spring-velocity-support:jar:0.0.1-SNAPSHOT
[INFO] +- commons-logging:commons-logging:jar:1.2:provided
[INFO] +- javax.servlet:javax.servlet-api:jar:4.0.1:provided
[INFO] +- org.slf4j:slf4j-api:jar:2.0.0-alpha1:provided
[INFO] +- org.slf4j:slf4j-simple:jar:2.0.0-alpha1:compile
[INFO] +- org.springframework:spring-context:jar:5.2.2.RELEASE:provided
[INFO] |  +- org.springframework:spring-aop:jar:5.2.2.RELEASE:provided
[INFO] |  +- org.springframework:spring-beans:jar:5.2.2.RELEASE:provided
[INFO] |  \- org.springframework:spring-expression:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-core:jar:5.2.2.RELEASE:provided
[INFO] |  \- org.springframework:spring-jcl:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-web:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-webmvc:jar:5.2.2.RELEASE:provided
[INFO] +- org.apache.velocity:velocity-engine-core:jar:2.1:provided
[INFO] |  \- org.apache.commons:commons-lang3:jar:3.9:compile
[INFO] +- org.apache.velocity.tools:velocity-tools-generic:jar:3.0:provided
[INFO] |  +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] |  |  \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] |  +- org.apache.commons:commons-digester3:jar:3.2:compile
[INFO] |  |  \- cglib:cglib:jar:2.2.2:compile
[INFO] |  |     \- asm:asm:jar:3.3.1:compile
[INFO] |  \- com.github.cliftonlabs:json-simple:jar:3.0.2:provided
[INFO] \- org.apache.velocity.tools:velocity-tools-view:jar:3.0:compile
java spring slf4j velocity
1个回答
0
投票

[runtime.log.instance绝对不是Velocity 2.1的软件包,它属于1.7版或更低版本(不使用slf4j)。]]

您的类路径中有一个旧的Velocity jar,它具有优先权。

如果您使用的是Maven,则可以显示依赖关系树以找到罪魁祸首:

mvn dependency:tree
© www.soinside.com 2019 - 2024. All rights reserved.