可以排除 spring-jcl 库吗?

huangapple go评论52阅读模式
英文:

can be spring-jcl libreary excluded?

问题

这是我的当前依赖树:

[INFO] +- org.springframework:spring-core:jar:6.0.5:compile
[INFO] |  \- org.springframework:spring-jcl:jar:6.0.5:compile
[INFO] +- org.springframework:spring-context:jar:6.0.5:compile
[INFO] |  +- org.springframework:spring-aop:jar:6.0.5:compile
[INFO] |  +- org.springframework:spring-beans:jar:6.0.5:compile
[INFO] |  \- org.springframework:spring-expression:jar:6.0.5:compile
[INFO] +- org.slf4j:slf4j-api:jar:2.0.6:compile
[INFO] \- ch.qos.logback:logback-classic:jar:1.4.5:compile
[INFO]    \- ch.qos.logback:logback-core:jar:1.4.5:compile
  1. 我不太清楚 org.springframework:spring-jcl:jar:6.0.5:compile 是什么。我可以从我的项目中排除它吗?
英文:

Here my current dependency tree:

[INFO] +- org.springframework:spring-core:jar:6.0.5:compile
[INFO] |  \- org.springframework:spring-jcl:jar:6.0.5:compile
[INFO] +- org.springframework:spring-context:jar:6.0.5:compile
[INFO] |  +- org.springframework:spring-aop:jar:6.0.5:compile
[INFO] |  +- org.springframework:spring-beans:jar:6.0.5:compile
[INFO] |  \- org.springframework:spring-expression:jar:6.0.5:compile
[INFO] +- org.slf4j:slf4j-api:jar:2.0.6:compile
[INFO] \- ch.qos.logback:logback-classic:jar:1.4.5:compile
[INFO]    \- ch.qos.logback:logback-core:jar:1.4.5:compile
  1. I don't quite figure out what's org.springframework:spring-jcl:jar:6.0.5:compile. Could I exclude it from my project?

答案1

得分: 1

根据Javadoc的说明:

Spring的变体Commons Logging API:具有对Log4J 2、SLF4J和java.util.logging的特殊支持。这是一种类似于jcl-over-slf4j的自定义桥接。如果您更喜欢硬绑定的SLF4J桥接,可以排除spring-jcl并切换到jcl-over-slf4j。但是,Spring自己的桥接在使用Log4J 2或java.util.logging时提供更好的开箱即用体验,无需额外的桥接jar,并且在Logback中更容易设置SLF4J(无需排除JCL,无需JCL桥接)。

日志等效于原始。但是,LogFactory是一个非常不同的实现,经过了最小化和优化,专为Spring的目的而设计,可以在框架类路径中检测到Log4J 2.x和SLF4J 1.7,然后回退到java.util.logging。如果您在使用此实现时遇到任何问题,请考虑排除spring-jcl并切换到标准的commons-logging工件或jcl-over-slf4j。

简而言之:这是适用于Spring的Commons Logging,是的,您可以排除它。但是,您可能需要包含不同的日志库。

英文:

According to the javadoc:

> Spring's variant of the Commons Logging API: with special support for Log4J 2, SLF4J and java.util.logging.
This is a custom bridge along the lines of jcl-over-slf4j. You may exclude spring-jcl and switch to jcl-over-slf4j instead if you prefer the hard-bound SLF4J bridge. However, Spring's own bridge provides a better out-of-the-box experience when using Log4J 2 or java.util.logging, with no extra bridge jars necessary, and also easier setup of SLF4J with Logback (no JCL exclude, no JCL bridge).
>
> Log is equivalent to the original. However, LogFactory is a very different implementation which is minimized and optimized for Spring's purposes, detecting Log4J 2.x and SLF4J 1.7 in the framework classpath and falling back to java.util.logging. If you run into any issues with this implementation, consider excluding spring-jcl and switching to the standard commons-logging artifact or to jcl-over-slf4j.

So tl;dr: It is commons logging adapted for Spring and yes, you can exclude it. But you then may need to include a different library for logging.

huangapple
  • 本文由 发表于 2023年3月3日 19:54:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/75626754.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定