gpt4 book ai didi

maven - IntelliJ IDEA 13 无法识别 Maven 镜像

转载 作者:行者123 更新时间:2023-12-03 23:08:50 31 4
gpt4 key购买 nike

我有一个 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 而不是(项目设置 > Maven > 存储库)。问题是,我无法从这个 repo 更新,因为我在内部网络上。在这种情况下我能做什么?

最佳答案

使用mirrorOf is discouraged ,因为它破坏了为促销(例如从快照到暂存到发布)、访问控制等使用单独的存储库的想法。Maven 中存在此功能,因为市场上没有适当的二进制存储库支持多个存储库,所以 Maven开发人员生活在一个代理为其代理的所有远程存储库公开一个 URL 的世界中。当然,这不再是事实。此设置的另一个用途是确保您的内部存储库不是依赖项 pom 文件中的存储库声明的快捷方式,而是 there are better solutions for this problem as well .

总而言之,不要使用mirrorOf。相反,您应该“隐藏”centralplugins 存储库,将它们替换为您的内部存储库 URL。

以下是 Artifactory 的 settings.xml 示例(对于 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>

关于maven - IntelliJ IDEA 13 无法识别 Maven 镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23997280/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com