Maven存储库问题

时间:2013-09-18 22:43:39

标签: spring maven maven-plugin pom.xml nexus

Maven尝试从端口8081上的localhost下载软件包/依赖项。这个nexus url接管是不受欢迎的,之前没有发生过。

运行通常的mvn clean install之后会发生这种情况:

Downloading:
http://192.168.10.46:8081/nexus/content/groups/public/org/codehaus/plexus/plexus-io/1.0/plexus-io-1.0.jar
Downloading: 
http://192.168.10.46:8081/nexus/content/groups/public/org/codehaus/plexus/plexus- archiver/1.0/plexus-archiver-1.0.jar
Downloading: http://192.168.10.46:8081/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.enonic.kurs:my-plugin:1.0.0-SNAPSHOT (/Users/xx yy/Documents/Enonic plugins/project/project/pom.xml) has 2 errors
[ERROR]     Unresolveable build extension: Plugin com.enonic.cms.tools:maven-cms-plugin:1.0.0 or one of its dependencies could not be resolved

从指定的存储库下载依赖项之前的所有时间。我的pom.xml中的存储库:

<pluginRepositories>
    <pluginRepository>
        <id>enonic</id>
        <name>Enonic Plugin Repository</name>
        <url>http://repo.enonic.com/maven</url>
    </pluginRepository>
</pluginRepositories>

<dependencies>
    <dependency>
        <groupId>com.enonic.cms</groupId>
        <artifactId>cms-api</artifactId>
        <version>4.4.10</version>
        <scope>provided</scope>
    </dependency>
   .........
   ---------
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>com.enonic.cms.tools</groupId>
            <artifactId>maven-cms-plugin</artifactId>
            <version>1.0.0</version>
            <extensions>true</extensions>
        </plugin>
    </plugins>
</build>

编辑:我认为我发现了问题,但还没有解决方法。 在构建插件com.enonic.cms.tools:maven-cms-plugin中,存在对plexus-utilsplexus-ioplexus-archiver的依赖关系,看起来这些存在连接问题,这会强制进行本地存储库查找。

调试信息:

[INFO] Scanning for projects...
[DEBUG] com.enonic.cms.tools:maven-cms-plugin:jar:1.0.0:
[DEBUG]    org.apache.maven:maven-plugin-api:jar:2.0.9:compile
[DEBUG]    org.apache.maven:maven-model:jar:2.0.9:compile
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.5.1:compile
[DEBUG]    org.apache.maven:maven-artifact:jar:2.0.9:compile
[DEBUG]    org.apache.maven:maven-project:jar:2.0.9:compile 
[DEBUG]       org.apache.maven:maven-settings:jar:2.0.9:compile
[DEBUG]       org.apache.maven:maven-profile:jar:2.0.9:compile
[DEBUG]       org.apache.maven:maven-artifact-manager:jar:2.0.9:compile
[DEBUG]          org.apache.maven:maven-repository-metadata:jar:2.0.9:compile
[DEBUG]       org.apache.maven:maven-plugin-registry:jar:2.0.9:compile
[DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[DEBUG]          junit:junit:jar:3.8.1:compile
[DEBUG]          classworlds:classworlds:jar:1.1-alpha-2:compile
[DEBUG]    org.apache.maven:maven-archiver:jar:2.4.1:compile
[DEBUG]       org.codehaus.plexus:plexus-archiver:jar:1.0:compile
[DEBUG]          org.codehaus.plexus:plexus-io:jar:1.0:compile
[DEBUG]       org.codehaus.plexus:plexus-interpolation:jar:1.13:compile
[DEBUG]    org.apache.maven.shared:maven-osgi:jar:0.2.0:compile
[DEBUG]       biz.aQute:bndlib:jar:0.0.203:compile
[DEBUG] Verifying availability of /Users/geir nygard/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.1/plexus-utils-1.5.1.jar from [nexus (http://192.168.10.46:8081/nexus/content/groups/public, releases+snapshots)]
[DEBUG] Verifying availability of /Users/geir nygard/.m2/repository/org/codehaus/plexus/plexus-archiver/1.0/plexus-archiver-1.0.jar from [nexus (http://192.168.10.46:8081/nexus/content/groups/public, releases+snapshots)]
[DEBUG] Verifying availability of /Users/geir nygard/.m2/repository/org/codehaus/plexus/plexus-io/1.0/plexus-io-1.0.jar from [nexus (http://192.168.10.46:8081/nexus/content/groups/public, releases+snapshots)]

将Settings.xml:

<settings>
<mirrors>
    <mirror>
        <!--This sends everything else to /public -->
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>http://192.168.10.46:8081/nexus/content/groups/public</url>
    </mirror>
</mirrors>
<profiles>
    <profile>
        <id>nexus</id>
        <!--Enable snapshots for the built in central repo to direct -->
        <!--all requests to nexus via the mirror -->
        <repositories>
            <repository>
                <id>central</id>
                <url>http://central</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>central</id>
                <url>http://central</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
      <!--make the profile active all the time -->
      <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

修改settings.xmlmirrorOf内容更改为*,!enonic后,我收到此错误:

ERROR] Error resolving version for plugin 'org.apache.maven.plugins:maven-install-plugin' from the repositories [local (/Users/xx yy/.m2/repository), enonic (http://repo.enonic.com/maven), nexus (http://192.168.10.46:8081/nexus/content/groups/public)]: Plugin not found in any plugin repository -> [Help 1]

1 个答案:

答案 0 :(得分:0)

你的设置xml文件的这一部分正是将仲裁存储库查找重定向到本地nexus repo的原因

<mirrors>
    <mirror>
        <!--This sends everything else to /public -->
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>http://192.168.10.46:8081/nexus/content/groups/public</url>
    </mirror>
</mirrors>

发生此问题是因为本地nexus存储库中不存在指定的工件。从xml设置中删除此部分,或修复本地存储库,使其正确镜像http://repo.enonic.com/maven

请注意,您还可以通过指定

来镜像除enonic之外的所有内容
<mirrorOf>*,!enonic</mirrorOf>

还要进一步查看settings.xml,我看到一些没有意义的部分,http://central是否已解决?不妨删除这个

  <repositories>
        <repository>
            <id>central</id>
            <url>http://central</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>central</id>
            <url>http://central</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
    </pluginRepositories>

我建议您在手册页上查看Maven基础知识:http://maven.apache.org/guides/index.html