我在我的pom.xml中有一个maven依赖:
<dependency>
<groupId>com.foo</groupId>
<artifactId>Bar</artifactId>
<version>1.2.3</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我想使用二进制的系统路径作为属性(因此我可以将它传递给由maven启动的外部进程).我可以用尴尬的方式做到这一点:
<properties>
<my.lib>${settings.localRepository}/com/foo/Bar/1.2.3/Bar.jar</my.lib>
</properties>
Run Code Online (Sandbox Code Playgroud)
但我真的想使用更标准的机制,例如:
<properties>
<my.lib>${com.foo:Bar:1.2.3}</my.lib>
</properties>
Run Code Online (Sandbox Code Playgroud)
我有可能这样吗?
我将用我的实际情况解释这个问题。
我使用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>
Run Code Online (Sandbox Code Playgroud)