【问题标题】:Project won't build when settings.xml exists当 settings.xml 存在时,项目不会构建
【发布时间】:2017-02-13 13:51:19
【问题描述】:

Unable to build maven project, pom.xml file not found 开始,我发现如果 settings.xml 存在,项目将无法构建。但是我需要 settings.xml 来告诉 maven 如何找到 Oracle ojdbc6.jar 文件。

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">

<servers>
<server>
  <id>build_server</id>
  <username>admin</username>
  <password>password</password>
</server>
</servers>

<profiles>
<profile>
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>libs-release</name>
      <url>http://build_server:8081/artifactory/libs-release</url>
    </repository>
    <repository>
      <snapshots />
      <id>snapshots</id>
      <name>libs-snapshot</name>
      <url>http://build_server:8081/artifactory/libs-snapshot</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>plugins-release</name>
      <url>http://build_server:8081/artifactory/plugins-release</url>
    </pluginRepository>
    <pluginRepository>
      <snapshots />
      <id>snapshots</id>
      <name>plugins-snapshot</name>
      <url>http://build_server:8081/artifactory/plugins-snapshot</url>
    </pluginRepository>
  </pluginRepositories>
  <id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>

</settings>

pom.xml 相当大(649 行),但如果上面的 settings.xml 不存在,项目会构建,但由于无法连接到 Oracle DB,因此单元测试失败。如果上述 settings.xml 文件确实存在,则它无法在 Artifactory 中找到如果 settings.xml 不存在则它确实找到的工件。

存储库和分发管理部分是:

<repositories>
  <snapshots>
    <enabled>false</enabled>
  </snapshots>
  <id>central</id>
  <name>libs-release</name>
  <url>http://build_server:8081/artifactory/libs-release</url>
</repository>
<repository>
  <snapshots />
  <id>snapshots</id>
  <name>libs-snapshot</name>
  <url>http://build_server:8081/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
  <snapshots>
    <enabled>false</enabled>
  </snapshots>
  <id>central</id>
  <name>plugins-release</name>
  <url>http://build_server:8081/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
  <snapshots />
  <id>snapshots</id>
  <name>plugins-snapshot</name>
  <url>http://build_server:8081/artifactory/plugins-snapshot</url>
</pluginRepository>

<pluginRepository>
  <id>maven.oracle.com</id>
  <name>oracle-maven-repo</name>
  <url>https://maven.oracle.com</url>
  <layout>default</layout>
  <releases>
    <enabled>true</enabled>
    <updatePolicy>always</updatePolicy>
  </releases>
</pluginRepository>

</pluginRepositories>

<distributionManagement>
<repository>
  <id>build_server</id>
  <name>build_server-releases</name>
  <url>http://build_server:8081/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
  <id>build_server</id>
  <name>build_server-snapshots</name>
  <url>http://build_server:8081/artifactory/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>

我非常困惑,希望得到一些指导。

build_server(不是它的真名)在 8081 端口上运行 artifactory,在 8111 上运行 teamcity。

谢谢

【问题讨论】:

  • 为什么投反对票?至少发表评论,以便我可以改进问题或解决构建问题。

标签: maven teamcity


【解决方案1】:

好的,所以问题出在 ID 上。我更改了 distributionManagement 部分中 pom.xml 中的 ID 以匹配 pluginRepositories 部分中的 ID,现在它可以工作了。

我希望这对其他人有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-13
    • 1970-01-01
    • 1970-01-01
    • 2017-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多