3

使用 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 没有帮助。下面的两个长答案也无济于事。

Nexus 公开

4

2 回答 2

1

It's not enough to configuration a mirrorof only you have to configure the following:

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

Apart from your configuration you need to delete your local repository and retry the build. Have you configured Nexus correctly to have access to the internet like maven central etc. ?

于 2013-01-05T11:26:04.377 回答
1

我不知道您是否拥有 Nexus 安装的管理员权限,但您必须在 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)。

于 2013-01-05T11:28:12.920 回答