Maven不使用配置的存储库来解决所有依赖关系

时间:2019-09-11 11:24:08

标签: maven gitlab-ci-runner

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

我们正在使用docker gitlab运行程序进行构建,而我正在使用运行 Apache Maven 3.5.4 maven: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'

一个明显的问题似乎是,行家正在尝试从repo.maven.apache.org而不是我的本地公司产品中检索休眠验证器。

我已经验证了相关罐子确实存在于我的人工制品中。我已经在本地(与Intellij捆绑在一起的docker maven版本3.6.1之外)以相同的设置构建了项目,并且没有任何问题。

有什么想法我在做什么错吗?

一些可能有用的文件

由help:有效设置生成的有效设置

<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>

1 个答案:

答案 0 :(得分:0)

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

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