我是Nexus新手,正在尝试在我的单个Nexus服务器上运行一个Maven项目。在运行项目时(已知的Spring Roo示例可以正确构建和运行),除了两个里程碑jar之外,所有的jar都已加载。我的答案(可能不是最好的)是直接找到jars并(使用POM)上传到我的Nexus服务器(托管的repo),然后我将其放在public组中。
当重新运行mvn项目(使用mvn包tomcat:run)时,这两个文件似乎是从服务器下载的(参见下面的控制台输出),但mvn项目仍然找不到。为什么项目显然会要求他们停下来,而不是使用他们?谢谢。
以下是控制台输出,显示下载正在进行,但没有被项目使用,以及我的settings.xml (有问题的jars是aspectjrt-1.6.11.M1和aspectjweaver-1.6.11.M1):
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>发布于 2011-11-15 06:19:43
首先,url http://central是正常的。它是一个永远不会使用的虚拟占位符,因为您已经定义了镜像。
然而,您使用的镜像url很可能是错误的。通常,Nexus中的存储库是托管或代理的,然后聚合到一个公共“组”中。
public组的url默认url是http://localhost:8081/nexus/content/groups/public/,如果您在apache后面代理或在端口80上运行,则本地主机将替换为您的服务器,并省略端口。
不管怎样..。要点是url是/content/GROUPS/public ..您的url很可能是错误的。只需在浏览器中尝试镜像中的url即可进行测试。
当然,您希望在public组中可用的所有存储库都必须添加到其中。
发布于 2011-11-17 12:49:06
因为您在自己的Nexus服务器上运行,所以jar在您配置的存储库上不可用。您应该将Spring源代码里程碑、版本和快照存储库添加到public组中。
OSS有一个Spring源代码库的实例,他们有一个包含里程碑、版本和快照的组url。链接为https://oss.sonatype.org/content/groups/springsource-all/
为此,您应该添加一个指向https://oss.sonatype.org/content/groups/springsource-all/的代理存储库,并将存储库策略设置为快照。
然后,将新的存储库添加到public组。最后,重新构建索引,Maven现在应该能够找到该文件。
此外,下面是一些使用Nexus配置Spring的有用链接。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/
https://stackoverflow.com/questions/8124884
复制相似问题