Maven在远程文件存储库中找不到工件 [英] Maven can't find artifacts in remote file repository

查看:97
本文介绍了Maven在远程文件存储库中找不到工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我正在一个封闭的网络中进行Maven项目,这意味着我无法连接到Maven Central.我有一个存储库文件夹,其中包含我需要的所有工件,包括插件和Maven工件.另外,我无法使用或安装Nexus.

Background: I'm working on a maven project in a closed network, which means I can't connect to Maven Central. I have a repository folder containing all the artifacts I should need, including plugins and maven artifacts. Also, I can't use or install Nexus.

问题:我想使用maven 3.6.0/jdk 1.8.0_162运行Jenkins作业.我的settings.xml文件如下:

Problem: I want to run a Jenkins job using maven 3.6.0 / jdk 1.8.0_162. My settings.xml file is as follows:

<?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>D:\Maven\repository</localRepository>

  <interactiveMode>false</interactiveMode>

  <offline>false</offline>

  <pluginGroups />

  <proxies />

  <servers />

  <mirrors>
    <mirror>
      <id>ExternalRespositoryMirror</id>
      <name>Maven External Repository Mirror</name>
      <url>file://myserver/repository/maven/repository</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>jenkins</id>
      <repositories>
        <repository>
          <id>central</id>
          <name>Maven External Dependencies Repository</name>
          <url>file://myserver/repository/maven/repository</url>
          <layout>default</layout>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <name>Maven External Plugins Repository</name>
          <url>file://myserver/repository/maven/repository</url>
          <layout>default</layout>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>jenkins</activeProfile>
  </activeProfiles>

</settings>

我的POM没有存储库部分,因为詹金斯奴隶应该确定从何处获得这些存储库.

My POM's have no repository section as the jenkins slave should determine where to get those.

构建时,出现以下错误:

When I build, I get the following error though:

[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-clean-plugin:jar:2.5 in ExternalRespositoryMirror (file://myserver/repository/maven/repository) -> [Help 1]

我可以打开文件://url,工件"maven-clean-plugin-2.5.jar"位于文件夹\ maven \ repository \ org \ apache \ maven \ plugins \ maven-clean-plugin \ 2.5中

I can open the file:// url and the artifact "maven-clean-plugin-2.5.jar" is in the folder \maven\repository\org\apache\maven\plugins\maven-clean-plugin\2.5

行家找不到工件的原因可能是什么?它存在于本地存储库(D:\ Maven \ repository)中,因此无论如何它实际上不应查询网络存储库.

What could be the reason that maven can't find the artifact? It is present in the local repository (D:\Maven\repository) so it shouldn't actually query the network repo anyway.

推荐答案

您可能想简单地尝试将罐子安装到本地存储库中,而只是跳过远程方面. Maven会先进入本地存储库,然后再进行远程操作.

You might want to simply try installing the jars into a local repository and just skip the remote aspect. Maven will look in the local repository before going remote.

安装第三方JAR的指南

创建一个pom进行复制,并将其绑定到process-resources阶段.您可以从已知位置(不要签入VCS;不当做法,浪费空间)拉出它们(例如:scp/robocopy/unzip)并安装它们.

Create a single pom to doing the copying, tie it to the process-resources phase. You can pull them (eg: scp/robocopy/unzip) from a known location (don't check into a VCS; bad practice, wasted space) and install them.

fyi,这与以太蚂蚁Tasks的工作相反,后者从amaven存储库中提取并复制到目标目录,这对于使用(nexus)存储库中的jar的蚂蚁构建非常有用,请参阅:

fyi, this is the opposite to what aether-ant Tasks does, which is pull from amaven repository and copy to a target directory, useful for ant builds to use jars from a (nexus) repository, see:

以太/蚂蚁任务

Apache Ant和Eclipse Aether

这篇关于Maven在远程文件存储库中找不到工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆