Detailed tutorial on deploying mvn deploy to nexus

Source: Internet
Author: User

When using maven to build a modular project, it is very frequent to package and release the project to the central repository. Configuration can simplify this process.

Settings. xml configure account password

<Servers>
<Server>
<Id> deploymentRepo </id>
<Username> admin </username>
<Password> admin123 </password>
</Server>
<Server>
<Id> snapshots </id>
<Username> admin </username>
<Password> admin123 </password>
</Server>
</Servers>
Directly deploy the jar package

Mvn deploy: deploy-file-DgroupId = com. renhenet-DartifactId = renhesoa-api-Dversion = 1.0.0-Dpackaging = jar-Dfile = target/renhesoa-api-1.0.0.jar-Durl = http: // localhost: 8083/content/repositories/thirdparty/-DrepositoryId = deploymentRepo

DrepositoryId is the server. id in setting. xml.

Use deploy plug-in

<Plugin>
<GroupId> org. apache. maven. plugins </groupId>
<ArtifactId> maven-deploy-plugin </artifactId>
<Version> 2.7 </version>
</Plugin>
After the deploy plug-in is added, an error is reported when mvn deploy is executed, as follows:
[ERROR] Failed to execute goal org. apache. maven. plugins: maven-deploy-plugin: 2.7: deploy (default-deploy) on project renhesoa-api: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in-DaltDeploymentRepository = id: layout: url parameter-> [Help 1]

You are also prompted to configure distributionManagement to specify DaltDeploymentRepository, as shown below:

<DistributionManagement>
<Repository>
<Id> deploymentRepo </id>
<Name> Nexus Renhe </name>
<Url> http: // localhost: 8083/content/repositories/thirdparty/</url>
</Repository>
</DistributionManagement>
Add the source code plug-in and release the source code package synchronously.

<Plugin>
<ArtifactId> maven-source-plugin </artifactId>
<Version> 2.4 </version>
<Executions>
<Execution>
<Phase> package </phase>
<Goals>
<Goal> jar-no-fork </goal>
</Goals>
</Execution>
</Executions>
</Plugin>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.