我已经通过mvn install: install-file将一个jar文件添加到我的本地maven存储库中,它在我的本地计算机上运行良好。这是我的 pom 中的依赖项:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>${oracle.connector.version}</version>
</dependency>
在我的机器上运行 mvn clean install 时,一切正常。 现在我有一个正在运行的本地 jenkins 实例(在 Windows 计算机上),它应该构建我的项目。构建遇到错误, Jenkins 说:
在mirror1 (http://repo.maven.apache.org/maven2) 中找不到 Artifact com.oracle:ojdbc6:jar:11.2.0 -> [帮助 1]
<?xml version="1.0" encoding="UTF-8" ?>
<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 http://maven.apache.org/xsd/
settings-1.0.0.xsd">
<localRepository>${user.home}/.m2/repository</localRepository>
<servers>
<server>
<id>nexusReleases</id>
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>nexusSnapshots</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
<mirrors>
<mirror>
<id>mirror1</id>
<mirrorOf>*</mirrorOf>
<name>Maven2 official repo</name>
<url>http://repo.maven.apache.org/maven2</url>
</mirror>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/repository/maven-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
当然,我已经仔细检查了 .m2 中的存储库目录。 ojdbc6.jar 就在那里。
那么我的设置有什么问题吗?
最佳答案
您可能想检查 Jenkins 使用什么作为其本地存储库。
转到Jenkins verwalten
(管理 Jenkins)
在 Maven-Projekt-Konfiguration
(Maven 项目配置)下,应该有一个 Jenkins .m2 存储库所在的设置。
如果这与您在本地使用的存储库不同,那就可以解释您的错误。
编辑:每个作业还有一个是否使用“私有(private)存储库”的选项。该存储库将特定于该作业,并且不会与任何其他存储库共享 Artifact 。
关于java - Jenkins 无法从本地存储库找到 Maven 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52037463/