神器已下载,但未在我的单个Nexus服务器中使用

时间:2011-11-14 16:40:25

标签: maven nexus

我是Nexus的新手,我正在尝试针对我的单个Nexus服务器运行Maven项目。在运行项目(Spring Roo示例已知可以构建并正确运行)时,除了两个里程碑jar之外,所有这些都已加载。我的答案(可能不是最好的)是直接找到并将罐子(用POM)上传到我的Nexus服务器(托管仓库),然后我将其放入公共组。

当重新运行mvn项目(使用mvn包tomcat:run)时,2个文件似乎从服务器下载(参见下面的控制台输出),但mvn项目仍然找不到。为什么该项目显然会打电话给他们但不使用它们?感谢。

以下是控制台输出,显示下载发生但未被项目使用,我的settings.xml(问题的jar是aspectjrt-1.6.11.M1和aspectjweaver-1.6.11.M1):< / p>

Last login: Mon Nov 14 06:03:25 on console
Macintosh-2:~ wlaprise$ cd coursemanager/
Macintosh-2:coursemanager wlaprise$ mvn package tomcat:run
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Course Manager Chapter 4 0.1.0.BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://www.c3works.com:8081/nexus-webapp-1.9.1.1/content/repositories/public/org/aspectj/aspectjrt/1.6.11.M1/aspectjrt-1.6.11.M1.pom
Downloaded: http://www.c3works.com:8081/nexus-webapp-1.9.1.1/content/repositories/public/org/aspectj/aspectjrt/1.6.11.M1/aspectjrt-1.6.11.M1.pom (909 B at 0.5 KB/sec)
Downloading: http://www.c3works.com:8081/nexus-webapp-1.9.1.1/content/repositories/public/org/aspectj/aspectjweaver/1.6.11.M1/aspectjweaver-1.6.11.M1.pom
Downloaded: http://www.c3works.com:8081/nexus-webapp-1.9.1.1/content/repositories/public/org/aspectj/aspectjweaver/1.6.11.M1/aspectjweaver-1.6.11.M1.pom (912 B at 1.0 KB/sec)
Downloading: http://www.c3works.com:8081/nexus-webapp-1.9.1.1/content/repositories/public/org/springframework/roo/org.springframework.roo.annotations/1.2.0.BUILD-SNAPSHOT/maven-metadata.xml
Downloading: http://www.c3works.com:8081/nexus-webapp-1.9.1.1/content/repositories/public/org/springframework/roo/org.springframework.roo.osgi.bundle/1.2.0.BUILD-SNAPSHOT/maven-metadata.xml
Downloading: http://www.c3works.com:8081/nexus-webapp-1.9.1.1/content/repositories/public/org/springframework/roo/org.springframework.roo.root/1.2.0.BUILD-SNAPSHOT/maven-metadata.xml
Downloading: http://www.c3works.com:8081/nexus-webapp-1.9.1.1/content/repositories/public/org/aspectj/aspectjrt/1.6.11.M1/aspectjrt-1.6.11.M1.jar
Downloading: http://www.c3works.com:8081/nexus-webapp-1.9.1.1/content/repositories/public/org/aspectj/aspectjweaver/1.6.11.M1/aspectjweaver-1.6.11.M1.jar
Downloaded: http://www.c3works.com:8081/nexus-webapp-1.9.1.1/content/repositories/public/org/aspectj/aspectjrt/1.6.11.M1/aspectjrt-1.6.11.M1.jar (1640 KB at 689.5 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.607s
[INFO] Finished at: Mon Nov 14 06:17:42 CST 2011
[INFO] Final Memory: 5M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project course-manager-chapter-04: Could not resolve dependencies for project org.rooinaction.coursemanager:course-manager-chapter-04:war:0.1.0.BUILD-SNAPSHOT: Could not find artifact org.aspectj:aspectjweaver:jar:1.6.11.M1 in nexus (http://www.c3works.com:8081/nexus-webapp-1.9.1.1/content/repositories/public) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Macintosh-2:coursemanager wlaprise$ 

settings.xml -

<settings>
    <mirrors>
        <mirror>
            <!--This sends everything else to /public -->
            <id>nexus</id>
            <mirrorOf>*</mirrorOf>
            <url>http://www.c3works.com:8081/nexus-webapp-1.9.1.1/content/repositories/public</url>
        </mirror>
    </mirrors>
    <profiles>
        <profile>
            <id>nexus</id>
            <!--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>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
    <pluginGroups>
        <pluginGroup>com.sonatype.maven.plugins</pluginGroup>
        <pluginGroup>org.sonatype.plugins</pluginGroup>
    </pluginGroups>
</settings>

2 个答案:

答案 0 :(得分:1)

首先,网址http://central很好。它是一个从未使用过的虚拟占位符,因为您定义了镜像。

然而,您使用它的镜像网址很可能是错误的。通常,Nexus中的存储库是托管或代理的,然后汇总到公共&#34;组&#34;中。

公共群组的网址默认网址为http://localhost:8081/nexus/content/groups/public/ 如果您在apache后面代理或在端口80上运行,则将localhost替换为您的服务器并省略端口。

无论如何..主要的一点是网址是/ content / GROUPS / public ..你的网址很可能是错误的。要测试只是在浏览器中尝试镜像中的URL。

当然,您希望公共组中可用的所有存储库都必须添加到其中。

答案 1 :(得分:0)

由于您在自己的Nexus服务器上运行,因此您配置的存储库中没有该jar。您应该将Spring Source里程碑,版本和快照存储库添加到公共组。

OSS有一个Spring Source存储库的实例,它们有一个包含里程碑,版本和快照的组URL。链接为https://oss.sonatype.org/content/groups/springsource-all/

为此,您应该添加一个指向https://oss.sonatype.org/content/groups/springsource-all/的代理存储库,并将存储库策略设置为Snapshot。

然后,将新存储库添加到公共组。最后,重建索引,Maven应该能够立即找到该文件。

此外,下面是一些配置Spring与Nexus的有用链接。 http://www.sonatype.com/people/2009/12/spring-maven-nexus-best-practices/ http://blog.springsource.com/2009/12/02/obtaining-spring-3-artifacts-with-maven/