gpt4 book ai didi

java - 如何识别不同 Java 版本的 Maven Artifact ?

转载 作者:行者123 更新时间:2023-11-29 05:33:55 24 4
gpt4 key购买 nike

我有一个针对 Java 1.7 和 Java 1.6 编译的 Maven 项目。1.7的jar是默认 Artifact ,不知道1.6的jar怎么识别。

我可以为 Artifact ID、版本添加后缀,或设置分类器。哪个是首选方式?当另一个项目 A 依赖于 1.7 jar,项目 B 依赖于 1.6 jar,项目 C 依赖于 A 时会发生什么B?

最佳答案

好吧,经过一些阅读,我认为分类器才是出路

来自maven docs

classifier: The classifier allows to distinguish artifacts that were built from the same POM but differ in their content. It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number. As a motivation for this element, consider for example a project that offers an artifact targeting JRE 1.5 but at the same time also an artifact that still supports JRE 1.4. The first artifact could be equipped with the classifier jdk15 and the second one with jdk14 such that clients can choose which one to use.

然后在项目 C's 中解决强制一个 jar 压倒另一个的问题pom,使用 <dependencyManagement>部分并在那里指定分类器。

希望对你有帮助

关于java - 如何识别不同 Java 版本的 Maven Artifact ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20165917/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com