1

我已经在我的 LAN 中设置了一个无法访问 Internet 的 Maven 存储库(Artifactory)。我还更改了我的 maven settings.xml 以仅使用此内部存储库。但是,当我尝试创建一个 maven 项目时,它仍然会尝试访问公共 repo( 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> 
4

0 回答 0