【发布时间】:2013-02-13 19:16:48
【问题描述】:
我会用我的实际情况来解释这个问题。
我使用 logback 1.0.1 进行日志记录,它包含 SLF4J 1.6.4 作为依赖项。我还将 SLF4J API 桥用于遗留日志 API(java.util.logging、log4j 和 commons-logging),它们不是显式依赖项。这些也必须(最好)是 1.6.4 版本。
为了使我的 pom.xml 尽可能整洁和无错误,我想强制这些 API 桥与 SLF4J 的版本相同。我知道的唯一方法是使用 1.6.4 版在我的 pom.xml 中手动将它们定义为依赖项。如果我更新了 logback 并提高了所需的 SLF4J 版本,我需要记住将桥 API 更改为正确的版本。
我能否以某种方式将遗留 API 的版本与传递依赖项 SLF4J 的版本挂钩?
当前 pom.xml:
<properties>
<org.slf4j.version>1.6.4</org.slf4j.version>
</properties>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.1</version>
<!-- requires SLF4J 1.6.4 -->
</dependency>
<!-- ... -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${org.slf4j.version}</version>
<!-- here, how to bind this version value to SLF4J's version? -->
<scope>runtime</scope>
</dependency>
<!-- the other two bridge API's go here -->
</dependencies>
【问题讨论】:
标签: java maven maven-2 dependency-management