Maven settings.xml中的存储库与插件存储库

时间:2018-08-01 12:30:41

标签: java maven nexus

我的〜/ .m2 / 文件夹中具有以下settings.xml文件:

<settings>
    <profiles>
        <profile>
            <id>my-repositories</id>
            <repositories>
                <repository>
                    <id>thirdparty-repository</id>
                    <name>Thirdparty repository</name>
                    <url>https://mynexus/repository/thirdparty/</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>thirdparty-plugin-repository</id>
                    <name>Thirdparty plugin repository</name>
                    <url>https://mynexus/repository/thirdparty/</url>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>my-repositories</activeProfile>
    </activeProfiles>
</settings>

对于两个存储库,使用相同的关系组存储库:

https://mynexus/repository/thirdparty/

如果我删除第一个:thirdparty-repository,则会出现以下错误:

Failed to read artifact descriptor for junit:junit:jar:4.8.2: Could not transfer artifact junit:junit:pom:4.8.2 from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

现在,如果我重新启用它,而是删除另一个:thirdparty-plugin-repository,我现在得到此错误:

 Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

只有当我同时启用它们时,它才能起作用。

为什么我需要同时指向同一个连结存储库的repositoriespluginRepositories

3 个答案:

答案 0 :(得分:0)

我有一个这样的pb,如果有帮助,请使用idk,但是有了POM.xml中的这段代码,我的联系pb就解决了

if ($request->hasFile('footerbanner')) {

$path = $request->file('footerbanner')->storeAs('public/upload',$request->footerbanner->getClientOriginalName().'.'.$extension);
}

    <distributionManagement>
    <repository>
        <id>nexus</id>
        <name>releases</name>
        <url>https://mynexus/repository/thirdparty/</url>
    </repository>
    <snapshotRepository>
        <id>nexus</id>
        <name>Snapshots</name>
        <url>https://mynexus/repository/thirdparty/</url>
    </snapshotRepository>
</distributionManagement>

希望有帮助

答案 1 :(得分:0)

在Nexus中定义了一个公共组,该组应包含所有需要的存储库,并且无需在您自己的pom或settings.xml文件中进行配置。仅应配置Nexus的公开组

您唯一需要做的就是使用自己的位置更改镜像中的网址...

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/repository/maven-public/</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

答案 2 :(得分:0)

假设您已经定义了一个具有某些依赖性的插件。这些依赖性将在您的所有<pluginRepository>定义中进行搜索。像这样:

<plugin>
   <groupId>org.liquibase</groupId>
   <artifactId>liquibase-maven-plugin</artifactId>
   <version>${liquibase.version}</version>
   <dependencies>
       <dependency>
          <groupId>io.herd.common</groupId>
          <artifactId>common-herd</artifactId>
          <version>${common.version}</version>
       </dependency>
   </dependencies>
</plugin>

即使您定义的<repository>包含普通牧羊工件,除非您也有<pluginRepository>包含它,否则Maven不会下载它。当然,通用工件不能存在于Maven中央存储库中。

几个月前我遇到了这个问题,在我添加<pluginRepository>

之后,Maven仅下载了特定的插件依赖项