首页 文章

Maven从不同存储库的一个插件下载文件

提问于
浏览
1

我有奇怪的问题 . 我有自己的远程存储库并上传他们的插件 . 然后我尝试在打包项目时下载它 . Maven开始从own_remote_repo下载,但下载1个文件开始在repo1.maven.org/maven2上搜索另一个文件,当然找不到插件并失败 .

我以前多次使用这个回购没有问题 .

[edit]

输出:

Downloading: http://repo1.maven.org/maven2/com/my/maven/plugin/maven-plugin/1.1.3/maven-plugin-1.1.3.pom
[INFO] Unable to find resource 'com.my.maven.plugin:maven-plugin:pom:1.1.3' in repository central (http://repo1.maven.org/maven2)
Downloading: http://<server>:<port>/nexus/content/groups/public/com/my/maven/plugin/maven-plugin/1.1.3/maven-plugin-1.1.3.pom
3K downloaded  (maven-plugin-1.1.3.pom)
Downloading: http://repo1.maven.org/maven2/com/my/maven/plugin/maven-plugin/1.1.3/maven-plugin-1.1.3.jar
[INFO] Unable to find resource 'com.my.maven.plugin:maven-plugin:maven-plugin:1.1.3' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] A required plugin was not found: Plugin could not be found - check that the goal name is correct: Unable to download the artifact from any repository

因此,你可以看到maven-plugin-1.1.3.pom maven的下载后尝试从maven中央仓库下载jar文件....

带有插件的jar文件位于nexus的同一目录中,名称等于maven尝试查找的jar文件 . 从nexus下载的maven-plugin-1.1.3.pom是正确的 .

有任何想法吗?

1 回答

  • 2

    我从你的问题中理解的是你只有插件问题,我们使用nexus作为代理并且必须配置

    $USER_HOME/.m2/settings.xml
    

    请检查下面显示的 pluginrepositories 部分的配置 .

    <settings>
        <mirrors>
            <mirror>
                <id>nexus</id>
                <mirrorof>*</mirrorof>
                <url>http://nexusurl/content/groups/public</url>
            </mirror>
        </mirrors>
        <profiles>
            <profile>
                <id>nexus</id>
                <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>
            <activeprofile>nexus</activeprofile>
        </activeprofiles>
    </settings>
    

相关问题