我有一个Maven项目,它为central
回购设置了一个镜像,像这样:
<settings>
...
<mirrors>
<mirror>
<id>central-my</id>
<mirrorOf>central</mirrorOf>
<name>Maven Central Repo mirror</name>
<url>http://local_url:15999/nexus/content/repositories/central/</url>
</mirror>
</mirrors>
...
</settings>
出于某种原因,当我导入此项目为IDEA,使其使用settings.xml
它仍然没有看到这面镜子,向我展示http://repo.maven.apache.org/maven2
,而不是(Project Settings
> Maven
> Repositories
)。问题是,由于我在内部网络上,因此无法从此存储库更新。在这种情况下我该怎么办?
mirrorOf
不鼓励使用,因为它破坏了为促销(例如,从快照到登台到发布),访问控制等使用单独的存储库的想法。自从市场上没有合适的二进制存储库支持多个存储库以来,Maven就存在此功能。 ,因此Maven开发人员生活在这个世界中,一个代理为它代理的所有远程存储库公开了一个URL。当然,这不再是事实。此设置的另一种用法是确保内部存储库不是依赖项pom文件中的存储库声明的快捷方式,但是对于此问题也有更好的解决方案。
总而言之,请勿使用mirrorOf
。相反,您应该“隐藏”central
和plugins
存储库,用内部存储库URL替换它们。
这是settings.xml
Artifactory的示例(对于Nexus应该与此类似):
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-releases</name>
<url>http://jbaruch.artifactoryonline.com/jbaruch/libs-releases</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>remote-snapshot-repos</name>
<url>http://jbaruch.artifactoryonline.com/jbaruch/remote-snapshot-repos</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-releases</name>
<url>http://jbaruch.artifactoryonline.com/jbaruch/plugins-releases</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshots</name>
<url>http://jbaruch.artifactoryonline.com/jbaruch/plugins-snapshots</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句