[英]Maven cannot Download from local repository (nexus) for some dependency or plugins
[英]Jenkins cannot find maven dependency from local repository
我已經通過mvn install:install- file在我的本地Maven存儲庫中添加了一個jar文件,該文件在我的本地計算機上運行良好。 這是我pom中的依賴項:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>${oracle.connector.version}</version>
</dependency>
在我的機器上運行mvn clean install時,一切正常。 現在,我有一個運行在Windows機器上的本地jenkins實例,該實例應該可以構建我的項目。 構建遇到錯誤,詹金斯說:
Could not find artifact com.oracle:ojdbc6:jar:11.2.0 in mirror1 (http://repo.maven.apache.org/maven2) -> [Help 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存儲庫。
如果那不是您在本地使用的同一存儲庫,那將解釋您的錯誤。
編輯:每個作業還有一個選項,無論是否使用“專用存儲庫”。 該存儲庫將特定於該作業,並且不會與其他任何資源共享工件。
我對ojdbc8.jar有同樣的問題。 由於我的pom.xml中存在此依賴性,構建失敗。
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3</version>
</dependency>
我將ojdbc8.jar復制到Jenkins Maven存儲庫。 將其重命名為ojdbc8-19.3.jar后,我的構建成功。
也許這可以幫助其他人。
使用以下依賴項:
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3.0.0</version>
</dependency>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.