有人可以帮助我理解为什么会发生以下情况吗?我想要依赖于jna版本4.1.0,但我认为我别无选择,只能依靠jna版本4.3.0。
如果我有"软"对jna的依赖我得到了这个。
$> grep -C2 jna pom.xml
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.1.0</version>
</dependency>
$> mvn dependency:tree |grep jna
[INFO] | \- <snip>:jar:1.7:runtime
[INFO] | \- net.java.dev.jna:jna-platform:jar:4.1.0:runtime
[INFO] +- net.java.dev.jna:jna:jar:4.1.0:compile
[INFO] | | \- <snip>:jar:1.7:runtime
[INFO] | | \- net.java.dev.jna:jna-platform:jar:4.1.0:runtime
[INFO] | +- net.java.dev.jna:jna:jar:4.1.0:compile
[INFO] +- net.java.dev.jna:jna:jar:4.1.0:compile
[INFO] | +- net.java.dev.jna:jna:jar:4.1.0:compile
[INFO] | \- net.java.dev.jna:jna:jar:4.1.0:compile
但是如果我将它改为对完全相同版本的硬依赖,那么已经使用ie 4.1.0,我得到了这个:
$> git diff
diff --git a/pom.xml b/pom.xml
index 57a14da..52bb525 100644
--- a/pom.xml
+++ b/pom.xml
@@ -596,7 +596,7 @@
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
- <version>4.1.0</version>
+ <version>[4.1.0]</version>
</dependency>
<dependency>
$> mvn dependency:tree |grep jna
[ERROR] Failed to execute goal on project <removed>: Could not resolve dependencies for project <removed>: Failed to collect dependencies for <snip>, net.java.dev.jna:jna:jar:[4.1.0,4.1.0] <snip> No versions available for net.java.dev.jna:jna:jar:[4.1.0] within specified range -> [Help 1]
现在,如果我对最近发布的4.3.0版本使用硬依赖,那么一切都好了!
$> git diff
diff --git a/pom.xml b/pom.xml
index 57a14da..52bb525 100644
--- a/pom.xml
+++ b/pom.xml
@@ -596,7 +596,7 @@
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
- <version>4.1.0</version>
+ <version>[4.3.0]</version>
</dependency>
<dependency>
$> mvn dependency:tree | grep jna
[INFO] | \- <snip>:jar:1.7:runtime
[INFO] | \- net.java.dev.jna:jna-platform:jar:4.1.0:runtime
[INFO] +- net.java.dev.jna:jna:jar:4.3.0:compile
[INFO] | | \- <snip>:jar:1.7:runtime
[INFO] | | \- net.java.dev.jna:jna-platform:jar:4.1.0:runtime
[INFO] | +- net.java.dev.jna:jna:jar:4.3.0:compile (version selected from constraint [4.3.0,4.3.0])
[INFO] +- net.java.dev.jna:jna:jar:4.3.0:compile
[INFO] | +- net.java.dev.jna:jna:jar:4.3.0:compile (version selected from constraint [4.3.0,4.3.0])
[INFO] | \- net.java.dev.jna:jna:jar:4.3.0:compile (version selected from constraint [4.3.0,4.3.0])