settings.xml 存在时项目不会生成
Project won't build when settings.xml exists
从 开始,我发现如果 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 数据库.如果上述 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。
谢谢
好的,原来是ID的问题。我更改了 distributionManagement 部分中 pom.xml 中的 ID 以匹配 pluginRepositories 部分中的 ID,现在它可以工作了。
我希望这对其他人有帮助。
从
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 数据库.如果上述 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。
谢谢
好的,原来是ID的问题。我更改了 distributionManagement 部分中 pom.xml 中的 ID 以匹配 pluginRepositories 部分中的 ID,现在它可以工作了。
我希望这对其他人有帮助。