Maven 未使用配置的存储库来解析所有依赖项



您好,我正在尝试使用带有我们自己的工件服务器的公司代理后面的 maven 构建一个 jar。

我们正在使用 docker gitlab 运行器进行构建,我正在使用运行Apache Maven 3.5.4maven:3-jdk-8映像。

通过从我们的工件工厂下载依赖项,构建开始得很好,但是当 maven-assembly-plugin 尝试将我们的输出打包到 jar 中时,我在调试模式下收到以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2.1:single (package-jar-with-dependencies) on project <my-project>: Failed to create assembly: Unable to resolve dependencies for assembly 'jar-with-dependencies': Failed to resolve dependencies for assembly: Unable to get dependency information for org.hibernate.validator:hibernate-validator:jar:6.0.13.Final: Failed to process POM for org.hibernate.validator:hibernate-validator:jar:6.0.13.Final: Non-resolvable import POM: Could not transfer artifact org.jboss.shrinkwrap:shrinkwrap-bom:pom:1.2.3 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: Name or service not known
[ERROR]   org.hibernate.validator:hibernate-validator:jar:6.0.13.Final
[ERROR] 
[ERROR] from the specified remote repositories:
[ERROR]   central (https://artifactory.corp.net/, releases=true, snapshots=false)
[ERROR] Path to dependency: 
[ERROR]     1) <my-project>
[ERROR]     2) org.springframework.boot:spring-boot-starter-web:jar:2.1.0.RELEASE: Unknown host repo.maven.apache.org: Name or service not known
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2.1:single (package-jar-with-dependencies) on project <my-project>: Failed to create assembly: Unable to resolve dependencies for assembly 'jar-with-dependencies'

明显的问题似乎是 maven 试图从repo.maven.apache.org而不是我当地的公司工件工厂检索休眠验证器。

我已经验证了有问题的罐子确实存在于我的工件中。我已经在本地构建了具有相同设置的项目(在与 Intellij 捆绑的 docker maven 版本 3.6.1 之外(,没有任何问题。

知道我做错了什么吗?

一些可能有用的文件

帮助生成的有效设置:有效设置

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<localRepository>path-to-my-repo</localRepository>
<servers>
<server>
<username>username</username>
<password>***</password>
<id>central</id>
</server>
<server>
<username>username</username>
<password>***</password>
<id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Artifactory</name>
<url>https://artifactory.corp.net/</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>Artifactory</name>
<url>https://artifactory.corp.net/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Artifactory</name>
<url>https://artifactory.corp.net/</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>Artifactory</name>
<url>https://artifactory.corp.net/</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
<pluginGroups>
<pluginGroup>org.apache.maven.plugins</pluginGroup>
<pluginGroup>org.codehaus.mojo</pluginGroup>
</pluginGroups>
</settings>

pom 文件中的插件配置

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>package-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>the.main.class</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>

这很可能是settings.xml中缺少镜像配置的结果。

如果要将每个请求发送到工件工厂,则需要将其指定为镜像。否则,也可以使用 POM 中的存储库定义。

最新更新