java - 在运行时更改工件版本
问题描述
我有一个 Maven 项目,它具有通过属性版本化的特定依赖项,即:
<properties>
<version.example-artifact>1.0.0</version.example-artifact>
</properties>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-artifact</artifactId>
<version>${version.example-artifact}</version>
</dependency>
</dependencies>
我有这个工件的多个次要版本:
1.0.0
1.1.0
它们与 API 兼容,因此其余代码可以针对其中一个进行编译,并且无需针对另一个重新编译即可运行。
从命令行,我可以这样做:
mvn exec:java -Dversion.example-artifact=1.1.0 ...
在运行项目时更改工件版本。
在 Eclipse 中是否仅在调试/运行配置中可能出现类似的情况?具体来说,我想避免改变 pom. 我试过添加:
-Dversion.example-artifact=1.1.0
到 VM 参数,但“显示命令行”表示它仍在使用 pom.xml 中定义的工件版本(即 1.0.0)。
解决方案
推荐阅读
- java - 有没有办法使用 PythonInterpreter 将 Python 代码的输出值(如“print('python code')”)返回到字符串或其他对象中
- javascript - 在ajax请求中使用2个函数
- javascript - 在同一路由Angular上将数据从一个解析器传递到另一个解析器
- flutter - 在颤动中删除下拉底线
- python - Win 错误 10060:我无法连接到服务器
- javascript - 加载特定页面时,如何在我的 Service Worker 上运行特定功能?
- javascript - 谷歌表格中的“脚本应用程序”是否会自动登录网站?
- javascript - 如何在 Angular 中为一个属性分配其他属性
- git - 克隆一个没有创建分支的拉取请求?
- python - 如何创建新变量而不是旧变量的链接?