【问题标题】:Maven repository issueMaven 存储库问题
【发布时间】:2013-09-18 22:43:38
【问题描述】:

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-utils、plexus-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)]

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.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]

【问题讨论】:

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


    【解决方案1】:

    您的设置 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

    【讨论】:

    • 在我的浏览器中,我可以连接到 url。据我所知,自上次工作以来没有任何变化。问题是 maven 尝试使用本地存储库?我应该在 settings.xml 中注释掉一些东西吗?
    • 我更新了我的帖子,提供了有关该问题的更多信息。我的 插件 (maven-cms-plugin) 中的依赖项存在一些查找问题
    • 请在~/.m2/settings.xml 或$M2_HOME/conf/settings.xml 上显示您的存储库镜像设置
    • 完成,贴在底部。
    • 现在出现新错误:ERROR] Error resolving version for plugin 'org.apache.maven.plugins:maven-install-plugin' from the repositories [local (/Users/geir nygard/.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 -&gt; [Help 1]
    猜你喜欢
    • 2010-12-08
    • 1970-01-01
    • 2020-12-27
    • 1970-01-01
    • 2011-06-25
    • 1970-01-01
    • 2021-11-21
    • 1970-01-01
    • 2012-08-17
    相关资源
    最近更新 更多