gpt4 book ai didi

java - 不同构建配置文件的不同依赖项

转载 作者:IT老高 更新时间:2023-10-28 11:23:51 26 4
gpt4 key购买 nike

maven pom.xml 文件中是否可以为不同的配置文件提供一组不同的依赖项?

例如

mvn -P debug
mvn -P release

我想在一个配置文件中选择一个不同的依赖 jar 文件,该文件具有相同的类名和相同接口(interface)的不同实现。

最佳答案

引用 Maven documentation on this :

A profile element contains both an optional activation (a profile trigger) and the set of changes to be made to the POM if that profile has been activated. For example, a project built for a test environment may point to a different database than that of the final deployment. Or dependencies may be pulled from different repositories based upon the JDK version used.

(重点是我的)

只需将 release 配置文件的依赖项放入配置文件声明本身,并对 debug 执行相同操作。

<profiles>    <profile>        <id>debug</id>        …        <dependencies>            <dependency>…</dependency>        </dependencies>        …    </profile>    <profile>        <id>release</id>        …        <dependencies>            <dependency>…</dependency>        </dependencies>        …    </profile></profiles>

关于java - 不同构建配置文件的不同依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/166895/

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