java - Maven:settings.xml 中的存储库

标签 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 中指定的存储库?

最佳答案

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

mvn ... -Pprofile-1

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

关于java - Maven:settings.xml 中的存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38852577/

相关文章:

java - 在 Java 中从数组中提取值

java - 创建部分为虚线和部分为实线的边框

java - Maven/mvn 警告 - 强烈建议解决这些问题,因为它们会威胁到构建的稳定性

java - 从命令行运行带有参数的 Maven 项目会出现错误

java - Maven 依赖项和 jetty - 避免部署

java - 将 C++ 类转换为等效的 Java 类

java - 在 TCP 服务器中使用 vertx Vertciles 的有效方法

java - Gradle:如何将 kotlin 和 java 保存在同一个源文件夹中?

java - 如何使用 Gradle 推送到 Github 包注册表

java - Spring Boot 2.1.5 Java 11 模块,组装 JAR : Could not create modular JAR file. 时出错 JDK jar 工具退出 1 -> [帮助 1]