-1

Maven 尝试从端口 8081 上的 localhost 下载包/依赖项。这种连接 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-io并且plexus-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)]

设置.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.xml更改mirrorOf内容 后,*,!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]
4

1 回答 1

0

您的设置 xml 文件的这一部分正是将任意存储库查找重定向到本地 nexus 存储库的原因

<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

于 2013-09-18T23:07:11.053 回答