如何禁用公共maven repo的使用

时间:2013-09-13 08:21:20

标签: maven repository artifactory

我在局域网中设置了一个没有互联网访问权限的maven存储库(Artifactory)。我还更改了我的maven settings.xml以仅使用此内部存储库。但是,当我尝试创建maven项目时,它仍尝试访问公共仓库(http://repo1.maven.org/maven2)进行一些下载。我哪里做错了?

例如,当我执行以下操作时:

mvn archetype:generate -DgroupId=demo.john -DartifactId=struts2demo 
    -DarchetypeGroupId=org.apache.struts 
    -DarchetypeArtifactId=struts2-archetype-starter 
    -DinteractiveMode=false

报告了以下警告:

... ...
[INFO] Generating project in Batch mode
[WARNING] Error reading archetype catalog http://repo1.maven.org/maven2
org.apache.maven.wagon.TransferFailedException: repo1.mavne.org
    at org.apache.maven.wagon.shared. ...
    ... ...

有时它会通过此警告成功构建,但有时它不会。

以下是我的maven的settings.xml

<?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">
  <servers>
    <server>
      <id>central</id>
      <username>admin</username>
      <password>password</password>
    </server>
    <server>
      <id>snapshots</id>
      <username>admin</username>
      <password>password</password>
    </server>
  </servers>
  <mirrors>
    <mirror>
      <id>my-company-repo</id>
      <name>A maven repo in local network</name>
      <url>http://my.internal.server/artifactory/repo<url>
    </mirror>
    <mirrorOf>*</mirrorOf>
  </mirrors>
  <profiles>
    <profile>
      <id>artifactory</id>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>http://my.internal.server/artifactory/libs-release</url>
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>http://my.internal.server/artifactory/libs-snapshot</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>plugins-release</name>
          <url>http://my.internal.server/artifactory/plugins-release</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>plugins-snapshot</name>
          <url>http://my.internal.server/artifactory/plugins-snapshot</url>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings> 

0 个答案:

没有答案