IntelliJ IDEA 13无法识别Maven镜像

时间:2014-06-02 14:45:39

标签: maven intellij-idea

我有一个Maven项目,其镜像设置为central repo,就像那样:

<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/maven2Project Settings&gt; { {1}}&gt; Maven)。问题是,我无法从此回购更新,因为我在内部网络上。在这种情况下我该怎么办?

1 个答案:

答案 0 :(得分:5)

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

总而言之,不要使用mirrorOf。相反,你应该&#34;影子&#34; 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>