Nexus和Maven的:访问Maven的中央回购?(Nexus and Maven: Access

2019-10-29 14:12发布

我有使用的Nexus和Maven一些麻烦。 当我尝试使用Maven Nexus的建设项目,Maven是无法找到任何神器。 我已将此添加到Maven的设置:

     <mirror>
       <id>nexus</id>
       <url>http://localhost:6060/nexus/content/groups/public</url>
       <mirrorOf>central</mirrorOf>
     </mirror>

到Maven与Nexus连接。 行家中央回购也设置在的Nexus设置中定义

Answer 1:

基于的文档上的Nexus您应该配置类似下面的settings.xml文件:

最重要的是,mirrorOf仅包含单asterik得到重定向到配置的Nexus实例的所有请求。

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/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>


Answer 2:

你可以尝试这样的:

<mirror>
    <id>nexus-local</id>
    <url>http://localhost:6060/nexus/content/groups/public/</url>
    <mirrorOf>external:*</mirrorOf>
</mirror>


文章来源: Nexus and Maven: Access to the Maven Central Repo?