maven deploy不适用于发行版

时间:2016-01-08 11:48:39

标签: maven repository maven-3 nexus snapshot

您好我是maven构建工具的初学者。我构建了一个简单的maven JavaEE项目,并尝试将其构建为远程 nexus存储库。但我只能成功部署快照。发布部署会导致400错误的请求错误。

这是我的Setting.xml配置

     <servers>
            <server>
                    <id>****</id>
                    <username>****</username>
                    <password>****</password>
            </server>
    </servers>

    <mirrors>
        <mirror>
                <id>nexus</id>
                <mirrorOf>central</mirrorOf>
                <url>http://******:8081/nexus/content/groups/net.******.timetrack/</url>
        </mirror>
    </mirrors>

<profiles>
    <profile>
            <id>nexus</id>
            <repositories>
                <repository>
                    <id>*****</id>
                    <url>http://******:8081/nexus/content/groups/net.*******.timetrack/</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
            </repositories>

            <pluginRepositories>
                <pluginRepository>
                    <id>******</id>
                    <url>http://******:8081/nexus/content/groups/net.******.timetrack/</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </pluginRepository>
            </pluginRepositories> 
        </profile>
</profiles>

<activeProfiles>
            <activeProfile>nexus</activeProfile>
</activeProfiles>

这是我的pom.xml分发管理

<distributionManagement>
        <repository>
            <uniqueVersion>false</uniqueVersion>
            <id>*****</id>
            <name>******</name>
            <url>http://*******:8081/nexus/content/groups/net.******.timetrack/</url>
            <layout>default</layout>
        </repository>
        <snapshotRepository>
            <uniqueVersion>true</uniqueVersion>
            <id>*****</id>
            <name>***** Snapshots</name>
            <url>http://******:8081/nexus/content/repositories/snapshots/</url>
            <layout>legacy</layout>
        </snapshotRepository>
    </distributionManagement>

如果我使用(用于快照)

运行mvn clean deploy
<groupId>net.*****.*****</groupId>
<artifactId>*****-**-****</artifactId>
<version>1.4-SNAPSHOT</version>
<packaging>war</packaging>

然后成功部署到nexus存储库快照目录。

如果我运行mvn clean deploy(用于发布)

<groupId>net.*****.****</groupId>
<artifactId>****-***-*****</artifactId>
<version>1.4.1</version>
<packaging>war</packaging>

然后它给出了400错误的请求错误

以下是错误的日志

[INFO] 
[INFO] --- maven-war-plugin:2.6:war (default-war) @ ****-****-***** ---
[INFO] Packaging webapp
[INFO] Assembling webapp [*****-time-tracker] in [/home/dilanka/Projects/time_tracker/samples/GitLab/****/***-time-tracker/target/*****-time-tracker-1.4]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/dilanka/Projects/time_tracker/samples/GitLab/*****/****-time-tracker/src/main/webapp]
[INFO] Webapp assembled in [115 msecs]
[INFO] Building war: /home/dilanka/Projects/time_tracker/samples/GitLab/TimeTracker/*****-time-tracker/target/****-time-tracker-1.4.war
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ ****-time-tracker ---
[INFO] Installing /home/dilanka/Projects/time_tracker/samples/GitLab/TimeTracker/****-time-tracker/target/****-time-tracker-1.4.war to /home/dilanka/maven3-repo/net/*****/timetrack/****-time-tracker/1.4/****-time-tracker-1.4.war
[INFO] Installing /home/dilanka/Projects/time_tracker/samples/GitLab/TimeTracker/****-time-tracker/pom.xml to /home/dilanka/maven3-repo/net/****/timetrack/****-time-tracker/1.4/****-time-tracker-1.4.pom
[INFO] 
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ ****-time-tracker ---
Uploading: http://*****:8081/nexus/content/groups/net.*****.timetrack/net/****s/timetrack/***-time-tracker/1.4/****-time-tracker-1.4.war
Uploading: http://*****:8081/nexus/content/groups/net.****.timetrack/net/****/timetrack/****-time-tracker/1.4/****-time-tracker-1.4.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.790 s
[INFO] Finished at: 2016-01-08T15:28:08+05:30
[INFO] Final Memory: 32M/252M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project ****-time-tracker: Failed to deploy artifacts: Could not transfer artifact net.****.timetrack:*****-time-tracker:war:1.4 from/to ***** (http://*****:8081/nexus/content/groups/net.****.timetrack/): Failed to transfer file: http://*****:8081/nexus/content/groups/net.****.timetrack/net/*****/timetrack/*****-time-tracker/1.4/****-time-tracker-1.4.war. Return code is: 400, ReasonPhrase: Bad Request. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

如果有人帮我解决这个问题。

感谢。

2 个答案:

答案 0 :(得分:0)

您可以将给定工件的发布版本一次部署到给定的Nexus实例。

如果您的Nexus中已经存在相同的版本,您将收到类似您所看到的错误。

答案 1 :(得分:0)

            <url>http://*******:8081/nexus/content/groups/net.****.timetrack/</url>

您无法部署到组存储库中,请将此URL更改为托管版本存储库的URL。