[英]in which maven life cycle, dependencies get downloaded from maven central repository to my local .m2 repository
[英]Maven dependencies from internal and central repository
我在Maven中有一个内部Nexus存储库,其中部署了一些插件。 有些依赖jar文件在nexus存储库中不存在,而有些则存在。 是否可以将maven配置为在内部存储库中搜索依赖jar文件,如果不存在则在maven中央存储库中搜索。
更新
做出与JimHawkins的回答类似的配置。 但我仍然认为它只关注依赖关系的nexus内部存储库。 以下是它打印的一些debus乱码:
[DEBUG] Using mirror Nexus (<internal-repo>) for central (repo1.maven.org/maven2).
[DEBUG] Using mirror Nexus (<internal-repo>) for Nexus (my.repository.com/repo/path)
[ERROR] Unresolveable build extension: Plugin <plugin-name> or one of its dependencies
could not be resolved: Failure to find org.co dehaus.plexus:plexus-utils:jar:1.1 in <internal-repo>
was cached in the local repository
如果你修改你的个人maven settings.xml
(位于<HOME>/.m2
/。m2),如下所示,maven会搜索你的Nexus的依赖项,而不是查看maven中央存储库。 如果maven在Nexus中找不到它们, Nexus将从 maven中央存储库下载它们 ,而不是将其提供给maven。
在从Nexus获取它之后,每个依赖项也存储在工作站上的本地maven存储库中
您可以告诉Nexus不仅在maven中央存储库中搜索新工件,还在其他公共存储库(例如JBoss公共存储库)中搜索新工件。
另请参见: Maven配置
在settings.xml
使用这些settings.xml
:
<mirrors>
<!--
mirror | Specifies a repository mirror site to use instead of a
given repository. The repository that | this mirror serves has an ID
that matches the mirrorOf element of this mirror. IDs are used | for
inheritance and direct lookup purposes, and must be unique across
the set of mirrors. | <mirror> <id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf> <name>Human Readable Name for this
Mirror.</name> <url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://your.internal-nexus.com/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.