Maven下载错误版本
我在 pom.xml 中指定了依赖项版本 75.1.3 指向我的其他项目之一:
<properties>
<myotherproject.version>75.1.3</myotherproject.version>
</properties>
<dependencies>
<dependency>
<groupId>com.myotherproject</groupId>
<artifactId>MyOtherProject</artifactId>
<version>${myotherproject.version}</version>
</dependency>
<dependencies>
但是当我 Maven 构建(全新安装)主项目时,maven 总是下载一些其他版本 75.1.1:
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] Downloading from maven-local: https://mycompany.com/maven-local/com/myotherproject/MyOtherProject/75.1.1/MyOtherProject-75.1.1.pom
[INFO] Downloaded from maven-local: https://mycompany.com/maven-local/com/myotherproject/MyOtherProject/75.1.1/MyOtherProject-75.1.1.pom (6.0 kB at 19 kB/s)
[INFO] Downloading from maven-local: https://mycompany.com/maven-local/com/myotherproject/MyOtherProject/75.1.1/MyOtherProject-75.1.1.jar
[INFO] Downloaded from maven-local: https://mycompany.com/maven-local/com/myotherproject/MyOtherProject/75.1.1/MyOtherProject-75.1.1.jar (329 kB at 918 kB/s)
我寻找了该版本75.1.1 并且在项目中没有提到它。对其他项目的依赖仅在该位置定义。当我从 .m2 文件夹中删除相应的文件夹 75.1.1 时,它会在每次构建时再次下载它。 当然,构建会由于缺少符号而失败(仅在 75.1.1 之后出现)。
我尝试在 pom.xml 中指定版本:75.1.2、75.1.3、75.1.4-SNAPSHOT,但它始终使用 75.1.1。
我还尝试将 maven-compiler-plugin 版本强制为 3.10.1,但这并不能解决问题。
我不知道现在还能尝试什么...我正在使用 Eclipse IDE。
I specified dependency version 75.1.3 in my pom.xml pointing to one of my other projects:
<properties>
<myotherproject.version>75.1.3</myotherproject.version>
</properties>
<dependencies>
<dependency>
<groupId>com.myotherproject</groupId>
<artifactId>MyOtherProject</artifactId>
<version>${myotherproject.version}</version>
</dependency>
<dependencies>
But when I maven build (clean install) the main project, maven always downloads some other version 75.1.1:
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] Downloading from maven-local: https://mycompany.com/maven-local/com/myotherproject/MyOtherProject/75.1.1/MyOtherProject-75.1.1.pom
[INFO] Downloaded from maven-local: https://mycompany.com/maven-local/com/myotherproject/MyOtherProject/75.1.1/MyOtherProject-75.1.1.pom (6.0 kB at 19 kB/s)
[INFO] Downloading from maven-local: https://mycompany.com/maven-local/com/myotherproject/MyOtherProject/75.1.1/MyOtherProject-75.1.1.jar
[INFO] Downloaded from maven-local: https://mycompany.com/maven-local/com/myotherproject/MyOtherProject/75.1.1/MyOtherProject-75.1.1.jar (329 kB at 918 kB/s)
I've looked for that version 75.1.1 and it's mentionned nowhere in the project. The dependency to the other project is defined only at that one place. When I delete the corresponding folder 75.1.1 from the .m2 folder, it downloads it again at each build.
And of course, the build fails due to a missing symbol (present only after 75.1.1).
I tried specifying versions: 75.1.2, 75.1.3, 75.1.4-SNAPSHOT in the pom.xml, but it always uses 75.1.1.
I've also tried forcing the maven-compiler-plugin version to 3.10.1 but it's not fixing the problem.
I don't know what else to try now... I'm using Eclipse IDE.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常这些问题是由其他(有时是间接的)依赖性引起的。
我建议您发出命令
dependency:tree
并检查谁依赖于旧的工件版本。Usually those problems are caused by other, sometimes indirect, dependencies.
I suggest you to issue the command
dependency:tree
and inspect who is that depends on the older artifact version.我终于找到原因了。
我的主项目的 pom.xml 中的版本已更新,但其子项目的 pom.xml 中的版本尚未更新。因此,子项目是基于旧快照构建的,引用旧版本的依赖项(另一个项目)。
我的想法是:
它实际上是什么:
所以问题出在父项目及其子项目之间,而不是 Maven 依赖项的错误。
I finally found the cause.
The version in the pom.xml of my main project had been updated, but not the version in the pom.xml of its child projects. Thus the child projects were built based on an old snapshot, referencing an older version of the dependency (the other project).
What I was thinking it was:
What it actually was:
So the problem was between the parent project and its children projects, not the fault of the maven dependency.