Maven:settings.xml中的存储库

时间:2016-08-09 13:46:41

标签: java maven

我关注.m2/settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <profiles>
    <profile>
      <repositories>

        <repository>
          <id>jboss-ga-repository</id>
          <url>http://maven.repository.redhat.com/techpreview/all</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>

      </repositories>
      <pluginRepositories>

        <pluginRepository>
          <id>jboss-ga-plugin-repository</id>
          <url>http://maven.repository.redhat.com/techpreview/all</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </pluginRepository>

      </pluginRepositories>
    </profile>
  </profiles>
</settings>

当我尝试对我的项目运行mvn install时,它说:

[INFO] Unable to find resource 'org.jboss.bom.eap:jboss-javaee-6.0-with-tools:pom:6.4.0.GA' in repository central (https://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: org.jboss.bom.eap:jboss-javaee-6.0-with-tools

Reason: POM 'org.jboss.bom.eap:jboss-javaee-6.0-with-tools' not found in repository: Unable to download the artifact from any repository

  org.jboss.bom.eap:jboss-javaee-6.0-with-tools:pom:6.4.0.GA

from the specified remote repositories:
  central (https://repo1.maven.org/maven2)

 for project org.jboss.bom.eap:jboss-javaee-6.0-with-tools

但它只尝试central (https://repo1.maven.org/maven2)。为什么忽略settings.xml中指定的存储库?

1 个答案:

答案 0 :(得分:1)

需要在Maven构建中激活配置文件。有几种方法可以激活它们(参见http://maven.apache.org/guides/introduction/introduction-to-profiles.html)。例如,您可以使用以下命令在命令行激活它:

mvn ... -Pprofile-1

但显然您需要在显示的<profile>节点中声明配置文件ID。