【问题标题】:Moving maven profiles in setting.xml to pom.xml将 setting.xml 中的 Maven 配置文件移动到 pom.xml
【发布时间】:2020-01-12 14:27:32
【问题描述】:

我正在使用 maven3。我在 settings.xml 中定义了一些用户特定的配置文件和 activeProfiles 标签,我想将它们移动到项目的 pom.xml。 但是仅仅将配置文件和 activeProfiles 从 settings.xml 复制到 pom.xml 是行不通的,并且会破坏构建,因为它试图在 maven Central 而不是工件中找到项目的父 pom。这是我的 settings.xml 配置文件。 Maven 报告问题: https://repo.maven.apache.org/maven2 中找不到 xxx:xxx:pom:19.2 失败被缓存在本地仓库中,直到 Central 的更新间隔已过或强制更新后才会重新尝试解析

有人可以帮忙吗?

{

    <profiles>
        <profile>
          <id>group</id>
          <repositories>
            <repository>
              <id>nb_releases</id>
              <name>Releases</name>
              <releases>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
              </releases>
              <snapshots>
                <enabled>false</enabled>
              </snapshots>
              <url>http://artifactory.xxxx.xxxx/nb-m2</url>
              <layout>default</layout>
            </repository>
          </repositories>
        </profile>

        <profile>
          <id>snapshots-group</id>
          <repositories>
            <repository>
              <id>nb_snapshots</id>
              <name>Snapshots</name>
              <releases>
                <enabled>false</enabled>
              </releases>
              <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
              </snapshots>
              <url>http://artifactory.xxxx.xxxx/nb-m2-snapshot</url>
              <layout>default</layout>
            </repository>
          </repositories>
        </profile>
        <profile>
          <id>plugins</id>
            <pluginRepositories>
              <pluginRepository>
                <id>nb_plugins</id>
                <name>Plugins</name>
                <releases>
                  <enabled>true</enabled>
                  <updatePolicy>never</updatePolicy>
                  <checksumPolicy>fail</checksumPolicy> 
                </releases>
                <snapshots>
                  <enabled>false</enabled>
                </snapshots>
                <url>http://artifactory.xxx.xxx/nb-m2</url>
                <layout>default</layout>
             </pluginRepository>
          </pluginRepositories>
      </profile>
    </profiles>
    <activeProfiles>
      <activeProfile>group</activeProfile>
      <activeProfile>snapshots-group</activeProfile>
      <activeProfile>plugins</activeProfile>
    </activeProfiles>
} 

【问题讨论】:

    标签: maven pom.xml


    【解决方案1】:

    标签&lt;activeProfiles&gt;只能在settings.xml中使用,不能在POM中使用。

    激活可在 POM 中使用的配置文件有多种可能性:

    https://maven.apache.org/guides/introduction/introduction-to-profiles.html

    【讨论】:

    • 感谢 JK Meier。我在配置文件的 pom 中添加了“激活”标签并解决了。 ` pluginstrue ... `
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-20
    • 1970-01-01
    • 2013-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-03
    相关资源
    最近更新 更多