简体   繁体   English

Maven 使用 JFrog Artifactory 的私有内部存储库未自动下载所需的插件

[英]Maven private internal repository using JFrog Artifactory not downloading the required plugins automatically

I have created a Private Local Maven Repository for dependency handling from Central Maven Server.我已经创建了一个私有本地 Maven 存储库,用于从中央 Maven 服务器进行依赖处理。 I have taken a sample project from JFrog's Maven Example to build the sample project.我从 JFrog 的 Maven 示例中获取了一个示例项目来构建示例项目。

I have followed all the steps for setting up the repository and able to make it up and running.我已按照所有步骤设置存储库并使其能够启动和运行。 When I try to build the application downloaded from https://github.com/jfrog/project-examples and the project is maven-example, I'm getting the following error.当我尝试构建从https://github.com/jfrog/project-examples下载的应用程序并且项目是 maven-example 时,我收到以下错误。

**root@xyz:/home/asdf/Downloads/mavenrepository/project-examples/maven-example# mvn deploy -U**

[INFO] Scanning for projects...

[INFO] ------------------------------------------------------------------------

[INFO] Reactor Build Order:

[INFO]

[INFO] Simple Multi Modules Build                                         [pom]

[INFO] Multi 1                                                            [jar]

[INFO] Multi 2                                                            [jar]

[INFO] Multi 3                                                            [war]

[INFO]

[INFO] ------------------------< org.jfrog.test:multi >------------------------

[INFO] Building Simple Multi Modules Build 3.7-SNAPSHOT                   [1/4]

[INFO] --------------------------------[ pom ]---------------------------------

Downloading from central: http://localhost:8081/artifactory/libs-release/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom

Downloading from snapshots: http://localhost:8081/artifactory/libs-snapshot/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom

[WARNING] The POM for org.apache.maven.plugins:maven-install-plugin:jar:2.4 is missing, no dependency information available

Downloading from central: http://localhost:8081/artifactory/libs-release/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.jar

Downloading from snapshots: http://localhost:8081/artifactory/libs-snapshot/org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.jar

[INFO] ------------------------------------------------------------------------

[INFO] Reactor Summary for Simple Multi Modules Build 3.7-SNAPSHOT:

[INFO]

[INFO] Simple Multi Modules Build ......................... FAILURE [  0.636 s]

[INFO] Multi 1 ............................................ SKIPPED

[INFO] Multi 2 ............................................ SKIPPED

[INFO] Multi 3 ............................................ SKIPPED

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time:  0.750 s

[INFO] Finished at: 2020-05-20T03:00:55+02:00

[INFO] ------------------------------------------------------------------------

[ERROR] Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-install-plugin:jar:2.4 in central (http://localhost:8081/artifactory/libs-release) -> [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/PluginResolutionException

I have already run the maven command mvn deploy -U to try to download the plugin and upload it to libs-release but it didn't work我已经运行了 maven 命令 mvn deploy -U 来尝试下载插件并将其上传到 libs-release 但它不起作用

I have also tried using the maven command mvn dependency:purge-local-repository but this also didn't update the required plugins.我也尝试过使用 maven 命令mvn dependency:purge-local-repository但这也没有更新所需的插件。

Now, how can we make the maven to download all the plugins again while building it and upload those plugins to JFrog Artifactory.现在,我们如何让 maven 在构建时再次下载所有插件并将这些插件上传到 JFrog Artifactory。

Also How to configure Maven settings.xml to download plugins which are not available in JFrog Artifactory / Private Internal Maven Repository and to get it from Maven Central Server ie, if a dependency is not available in Private Internal Maven Repository, Maven should download it from Central Maven Repository. Also How to configure Maven settings.xml to download plugins which are not available in JFrog Artifactory / Private Internal Maven Repository and to get it from Maven Central Server ie, if a dependency is not available in Private Internal Maven Repository, Maven should download it from中央 Maven 存储库。

Please help support.请帮忙支持。

settings.xml file settings.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  
  <servers>
    <server>
      <username>xyz</username>
      <password>xyz_pass</password>
      <id>central</id>
    </server>
    <server>
      <username>admin</username>
      <password>admin_password</password>
      <id>snapshots</id>
    </server>
  </servers>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>http://localhost:8081/artifactory/libs-release</url>       
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>http://localhost:8081/artifactory/libs-snapshot</url>          
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>http://localhost:8081/artifactory/libs-release</url>             
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>http://localhost:8081/artifactory/libs-snapshot</url>          
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>

Trace:
Request ID: 2ba338df
Repo Path ID: libs-release:org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
Method Name: GET
User: admin
Time: 2020-05-26T10:32:01.113+02:00
Thread: http-nio-8081-exec-9
Steps: 
2020-05-26T10:32:01.113+02:00 Received request
2020-05-26T10:32:01.114+02:00 Request source = 10.XXX.XXX.XXX, Last modified = 01-01-70 00:59:59 +01:00, If modified since = -1, Thread name = http-nio-8081-exec-9
2020-05-26T10:32:01.114+02:00 Executing any BeforeDownloadRequest user plugins that may exist
2020-05-26T10:32:01.114+02:00 Retrieving info from virtual repository 'libs-release' type Maven
2020-05-26T10:32:01.114+02:00 Consulting the virtual repo download strategy
2020-05-26T10:32:01.114+02:00 Trying to retrieve resource info from the local storage
2020-05-26T10:32:01.114+02:00 Unable to find resource in libs-release:org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
2020-05-26T10:32:01.114+02:00 Intercepting cached virtual resource with 'MavenMetadataInterceptor'
2020-05-26T10:32:01.114+02:00 Intercepting cached virtual resource with 'PomInterceptor'
2020-05-26T10:32:01.114+02:00 Searching for info in aggregated repositories
2020-05-26T10:32:01.114+02:00 Preparing list of aggregated repositories to search in
2020-05-26T10:32:01.114+02:00 Appending the nested virtual repository 'libs-release'
2020-05-26T10:32:01.115+02:00 Appending collective local repositories
2020-05-26T10:32:01.115+02:00 Appending collective local cache repositories
2020-05-26T10:32:01.115+02:00 Appending collective remote repositories
2020-05-26T10:32:01.115+02:00 Intercepting info request with 'MavenMetadataInterceptor'
2020-05-26T10:32:01.115+02:00 Intercepting info request with 'PomInterceptor'
2020-05-26T10:32:01.115+02:00 Processing request as a release resource
2020-05-26T10:32:01.115+02:00 Searching for the resource within libs-release-local
2020-05-26T10:32:01.115+02:00 Unable to find resource in libs-release-local:org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
2020-05-26T10:32:01.115+02:00 Searching for the resource within jcenter-cache
2020-05-26T10:32:01.115+02:00 Unable to find resource in jcenter-cache:org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
2020-05-26T10:32:01.115+02:00 Searching for the resource within jcenter
2020-05-26T10:32:01.116+02:00 Unable to find resource in jcenter-cache:org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
2020-05-26T10:32:01.116+02:00 Repository is assumed offline and the resource doesn't exist in the local cache - returning unfound resource
2020-05-26T10:32:01.116+02:00 Returning an unfound resource
2020-05-26T10:32:01.116+02:00 Requested resource is found = false
2020-05-26T10:32:01.116+02:00 Requested resource is blocked = false
2020-05-26T10:32:01.116+02:00 Request is HEAD = false
2020-05-26T10:32:01.116+02:00 Request is for a checksum = false
2020-05-26T10:32:01.116+02:00 Target repository is not remote or doesn't store locally = true
2020-05-26T10:32:01.116+02:00 Requested resource was not modified = false
2020-05-26T10:32:01.116+02:00 Responding with unfound resource
2020-05-26T10:32:01.116+02:00 Setting default response status to '404' reason to 'Resource not found'
2020-05-26T10:32:01.116+02:00 Response is an instance of UnfoundRepoResourceReason
2020-05-26T10:32:01.116+02:00 Configured to hide un-authorized resources = false
2020-05-26T10:32:01.116+02:00 Original response status is auth related = false
2020-05-26T10:32:01.116+02:00 Using original response status of '404' and message 'Could not find resource'
2020-05-26T10:32:01.116+02:00 Sending error with status 404 and message 'Could not find resource'
2020-05-26T10:32:01.116+02:00 Executing any AfterDownloadErrorAction user plugins that may exist
2020-05-26T10:32:01.116+02:00 Response code wasn't modified by the user plugins
2020-05-26T10:32:01.116+02:00 Sending response with the status '404' and the message 'Could not find resource'

Based on the trace provided in the question, the issue seems to be with access to the JCenter public repository.根据问题中提供的跟踪,问题似乎与访问 JCenter 公共存储库有关。
The following lines in the trace is showing that the requested artifact in not cached locally and Artifactory is trying to request it from JCenter, but it is assumed offline:跟踪中的以下行显示请求的工件未在本地缓存,并且 Artifactory 正在尝试从 JCenter 请求它,但假定它处于脱机状态:

2020-05-26T10:32:01.115+02:00 Searching for the resource within jcenter
2020-05-26T10:32:01.116+02:00 Unable to find resource in jcenter-cache:org/apache/maven/plugins/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
2020-05-26T10:32:01.116+02:00 Repository is assumed offline and the resource doesn't exist in the local cache - returning unfound resource

This means that Artifactory did not manage to reach to jcenter a couple of times with success and eventually marked it as offline.这意味着 Artifactory 未能成功访问 jcenter 几次,最终将其标记为离线。
This can happen for several reasons, including as suggested in the comments a firewall which is blocking outgoing traffic to JCenter.发生这种情况的原因有很多,包括如评论中所建议的那样,防火墙阻止了到 JCenter 的传出流量。
The best way to troubleshoot it would be getting the JCenter repository URL from the repository configuration and making sure you have network access to it.解决它的最佳方法是从存储库配置中获取 JCenter 存储库 URL 并确保您可以通过网络访问它。
One thing to notice regarding JCenter - recently, for security reasons, it started enforcing the use of secure HTTP (https).关于 JCenter 需要注意的一件事 - 最近,出于安全原因,它开始强制使用安全的 HTTP (https)。 There is a chance your configuration is still using non secure HTTP, which can lead to requests failing.您的配置可能仍在使用非安全 HTTP,这可能导致请求失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM