使用Nexus时无法编译Spring Roo项目

时间:2013-01-05 10:51:16

标签: maven spring-roo nexus

使用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 public

2 个答案:

答案 0 :(得分:1)

配置镜像是不够的,只需要配置以下内容:

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

答案 1 :(得分:1)

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

你必须添加的回购是

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不会连接到默认centralrepo1.maven.org)。