【问题标题】:Can't compile Spring Roo project when using Nexus使用 Nexus 时无法编译 Spring Roo 项目
【发布时间】:2013-01-05 10:51:15
【问题描述】:

使用 Nexus 时无法编译 Spring Roo (1.2.3.RELEASE) 项目。

mvn 说找不到 roo.annotations:jar

[ERROR] Failed to execute goal on project Roo123: Could not resolve dependencies for project com.example.roo:Roo123:jar:0.1.0.BUILD-SNAPSHOT: Failure to find org.springframework.roo:org.springframework.roo.annotations:jar:1.2.3.RELEASE in http://192.168.16.232:8081/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]

但是这个 jar 已经在本地 maven 存储库中了。

禁用 Nexus 时,通过重命名 .m2\settings.xml,它可以正常工作。

settings.xml 只配置了 1 个镜像

<mirror>
  <id>nexus</id>
  <mirrorOf>*</mirrorOf>
  <url>http://192.168.16.232:8081/nexus/content/groups/public</url>
</mirror>    

如何配置 Nexus?

(添加 http://spring-roo-repository.springsource.org/release 作为代理存储库没有帮助)

更新:添加图片。在左侧添加 spring-roo-repository 没有帮助。 下面的两个长答案也无济于事。

【问题讨论】:

    标签: maven spring-roo nexus


    【解决方案1】:

    只配置一个mirrorof是不够的,你需要配置如下:

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

    除了您的配置之外,您还需要删除本地存储库并重试构建。您是否正确配置 Nexus 以访问 maven Central 等互联网?

    【讨论】:

    • 我不明白。为什么我需要创建配置文件并使其处于活动状态?当一切都已经在 content/groups/public 中时,central 是什么意思?并且删除本地存储库(如果它没有损坏)通常是不好的建议。
    【解决方案2】:

    我不知道您是否拥有 Nexus 安装的管理员权限,但您必须将 a new proxy repository 添加到您的 Nexus 安装中。

    你必须添加的仓库是

    http://spring-roo-repository.springsource.org/release
    

    您应该有一个如下所示的设置文件(与 khmarbaise 的版本略有不同):

    <settings
        xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
          <servers>  
              <server>  
                  <id>central</id>  
                  <username>your-user</username>  
                  <password>your-user</password>  
              </server>  
              <server>  
                  <id>mirror</id>  
                  <username>your-user</username>  
                  <password>your-user</password>  
              </server>  
          </servers>  
          <mirrors>  
            <mirror>  
                <id>mirror</id>  
                <url>https://url.to.your.nexus</url>  
                <mirrorOf>*</mirrorOf>  
            </mirror>  
          </mirrors>  
          <profiles>  
              <profile>  
                  <id>defaultprofile</id>  
                  <repositories>  
                      <repository>  
                          <id>central</id>  
                        <name>Repository for your artifacts</name>  
                          <url>https://url.to.your.nexus</url>  
                          <releases>  
                              <enabled>true</enabled>  
                        </releases>  
                          <snapshots>  
                              <enabled>true</enabled>  
                        </snapshots>  
                      </repository>  
                  </repositories>  
                  <pluginRepositories>  
                      <pluginRepository>  
                          <id>central</id>  
                        <name>Repository for your artifacts</name>  
                          <url>https://url.to.your.nexus</url>  
                          <releases>  
                              <enabled>true</enabled>  
                        </releases>  
                          <snapshots>  
                              <enabled>true</enabled>  
                        </snapshots>  
                      </pluginRepository>  
                  </pluginRepositories>  
                  <properties>  
                      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
                  </properties>  
                  <activation>  
                      <activeByDefault>true</activeByDefault>  
                  </activation>  
              </profile>  
          </profiles>  
          <activeProfiles>  
              <activeProfile>defaultprofile</activeProfile>  
          </activeProfiles>  
    </settings>
    

    您必须覆盖 central(见上文),这样 Maven 就不会连接到默认的 central (repo1.maven.org)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-08
      • 1970-01-01
      • 1970-01-01
      • 2014-08-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多