Maven - 存储库标记阻止部署

cdu*_*gan 1 nexus maven

我有一个项目POM,它指定一个指向沙箱位置的存储库标记.

<repositories>
    <repository>
        <id>mysandbox</id>
        <name>Sandbox</name>
        <url>http://myTestingSite.com/repositories/sandbox/</url>
    </repository>
</repositories>
Run Code Online (Sandbox Code Playgroud)

这在Eclipse中工作正常并解析所有依赖项,但是当我尝试部署时,我得到以下异常.

   [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-depl
    oy) on project myweb-web: Deployment failed: repository element was not specified in the POM insid
    e distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help
    1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plug
    ins:maven-deploy-plugin:2.5:deploy (default-deploy) on project myweb-web: Deployment failed: repos
    itory element was not specified in the POM inside distributionManagement element or in -DaltDeployme
    ntRepository=id::layout::url parameter
Run Code Online (Sandbox Code Playgroud)

在Distributionmanagement元素中包含它没有任何意义,因为我使用存储库来进行依赖项解析而不是部署.

Aar*_*lla 7

错误表示您要么没有distributionManagement元素,要么元素不正确.

所以这与内容无关<repositories>.只需创建一个正确的distributionManagement元素,它就会起作用.

请注意,损坏的元素可能位于父POM中.运行mvn help:effective-pom以查看Maven看到的完整POM.


Aug*_*sto 6

您最初定义的存储库仅考虑下载依赖项,而不是上传它们(如您所述).

您需要添加的是分发管理中的存储库

<distributionManagement>
    <repository>
        <id>id</id>
        <name>name</name>
        <url>nexus_url</url>
    </repository>
</distributionManagement>
Run Code Online (Sandbox Code Playgroud)

如果你的nexus是安全的,你还需要为密码定义一个服务器部分.

<servers>
    <server>
        <id>id</id>
        <username>username</username>
        <password>password</password>
    </server>
</servers>
Run Code Online (Sandbox Code Playgroud)