java - Maven 找不到本地 Artifact

标签 java maven jenkins

我安装了一个无法通过 Maven Central 使用的本地 Artifact :

mvn install:install-file -Dfile=/app/x/ema.jar -DgroupId=org.x -DartifactId=elektron -Dversion=3.0.4 -Dpackaging=jar

本地存储库现在具有以下结构:

user@server:~/.m2/repository/org/x/elektron/3.0.4# ll
total 592
drwxr-xr-x 2 root root   4096 Mar 28 11:43 ./
drwxr-xr-x 3 root root   4096 Mar 28 11:43 ../
-rw-r--r-- 1 root root 588185 Dec  9 20:12 elektron-3.0.4.jar
-rw-r--r-- 1 root root    463 Mar 28 11:43 elektron-3.0.4.pom
-rw-r--r-- 1 root root    175 Mar 28 11:43 _remote.repositories

elektron-3.0.4.pom的内容是:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.x</groupId>
  <artifactId>elektron</artifactId>
  <version>3.0.4</version>
  <description>POM was created from install:install-file</description>
</project>

我的 pom 有以下依赖项:

<dependency>
    <groupId>org.x</groupId>
    <artifactId>elektron</artifactId>
    <version>3.0.4</version>
</dependency>

当我通过 Jenkins 构建时,出现以下错误:

[WARNING] The POM for org.x:elektron:jar:3.0.4 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.253 s
[INFO] Finished at: 2017-03-28T11:35:27-04:00
[INFO] Final Memory: 17M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project ampere: Could not resolve dependencies for project y:ampere:jar:0.1.8-SNAPSHOT: Failure to find org.x:elektron:jar:3.0.4 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

我尝试过推荐的解决方案(删除/重新安装、删除 *.repositories 文件),但似乎都不起作用。

有什么想法吗?

最佳答案

当查看我的 Jenkins .m2 存储库时,它包含以下内容:

user@server:/var/lib/jenkins/.m2/repository/org/x/elektron/3.0.4# ll
total 596
drwxr-xr-x 2 jenkins jenkins   4096 Mar 28 12:03 ./
drwxr-xr-x 3 jenkins jenkins   4096 Mar 24 15:23 ../
-rw-r--r-- 1 jenkins jenkins    244 Mar 28 11:23 elektron-3.0.4.jar.lastUpdated
-rw-r--r-- 1 jenkins jenkins    244 Mar 28 11:23 elektron-3.0.4.pom.lastUpdated

我手动添加了以下两个文件,它起作用了:

-rw-r--r-- 1 root    root    588185 Mar 28 12:03 elektron-3.0.4.jar
-rw-r--r-- 1 root    root       463 Mar 28 12:03 elektron-3.0.4.pom

关于java - Maven 找不到本地 Artifact ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43074097/

相关文章:

java - 将 spark 数据集保存到现有的 csv 文件

java - NoClassDefFoundError : scala/Product$class

jenkins - 如何解析数据,并写入 JSON 文件

git - Jenkins Git 环境变量未在管道中设置

java - 如何让 tomcat 同时托管 jenkins 和 sonar 而不会因 OutOfMemoryException 而崩溃?

java - Spring 的@DependsOn 不能处理应用程序事件?

java - 如何将 javafx 正确导入 eclipse? ("The import cannot be resolved")

java - xcodebuild 打印了太多日志

java - 从 java 1.7 升级到 1.8 后,使用 Maven 编译错误,但在 Eclipse 中没有

java - Jenkins 找不到通过 Eclipse 为 selenium 项目添加的外部 Jars