java - 当我使用 Nexus 进行代理时,如何在 pom 中添加自定义存储库?

标签 java maven nexus

我正在尝试使用 Nexus 来代理中央存储库,但速度相当慢。 所以。我已经根据教程配置了maven。

<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>
     </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>  

一切都运行良好且快速。但是当我尝试使用 pom.xml 中指定的自定义存储库时,我遇到了问题(仅具体项目需要此存储库)

所以。我说的是:

<pluginRepositories>
  <pluginRepository>
    <id>dtrott</id>
    <url>http://maven.davidtrott.com/repository</url>
  </pluginRepository>
</pluginRepositories>  

来自:https://github.com/dtrott/maven-protoc-plugin#readme

错误消息:

Error resolving version for plugin 'com.google.protobuf.tools:maven-protoc-plugin' from the repositories [local (C:\Users\valden\.m2\repository), nexus (http://localhost:8081/nexus/content/groups/public)]: Plugin not found in any plugin repository -> [Help 1]  

在 Maven settings.xml 中,我更改了下一行:

<mirrorOf>*</mirrorOf>  

<mirrorOf>central</mirrorOf>  

现在正在工作......

最佳答案

一种选择是将自定义存储库作为代理存储库(类型 proxy)添加到您的 Nexus 中。那么您就不必在您的 pom 中添加任何额外的内容。

关于java - 当我使用 Nexus 进行代理时,如何在 pom 中添加自定义存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10085754/

相关文章:

java - Android 中的自定义进度条?

java - 如何找出for循环迭代是否是最后一次

java - 使用 hibernate 和 dbunit maven 插件创建内存数据库时出现问题

java - 如何同时从 Jenkins 运行多个 Selenium 测试?

gwt - Eclipse 中的 Maven 子模块 : Resources from one module not found in another

sbt - 如何使用 sbt 访问安全的 Nexus?

java - 使用递归方法查找字符串中的单词数

java - 我如何模拟类路径中属性文件的存在?

node.js - 兼容 Nexus 的存储库,用于获取 Node 和 npm 安装程序

repository - 可以将二进制文件放在 nexus 存储库中吗?