This article focuses on how you can connect to a good maven and nexus, that is, how to deploy artifact to a nexus via Maven.
The premise of this article:
1. Install Maven. You can use Maven to create and package projects. About installation
2. Install the Nexus. Access to the local Nexus warehouse http://localhost:8081/nexus/#welcome.
Body:
1. Configure MAVEN configuration file Settings.xml and the project's description file Pom.xml, so that Maven knows where to deploy and has permission to deploy.
In the Setting.xml:
<Servers> <Server> <ID>Xxx-nexus</ID> <username>Deployment</username> <Password>{DEPLOYMENT_PWD}</Password> </Server> </Servers>
Recommended to use deployment account, this account after the installation of the Nexus has been, the default password is deployment123, you can modify this password.
In the Pom.xml:
<distributionmanagement> <!--Publish The versioned releases here - <Repository> <ID>Xxx-nexus</ID> <name>Vineetmanohar Nexus</name> <URL>http://localhost:8081/nexus/content/repositories/releases/</URL> </Repository> <!--Publish The versioned releases here - <snapshotrepository> <ID>Xxx-nexus</ID> <name>Vineetmanohar Nexus</name> <URL>http://localhost:8081/nexus/content/repositories/snapshots/</URL> </snapshotrepository> </distributionmanagement>
Note that the ID of the <repository> element and the <snapshotRepository> element should be consistent with the ID in the settings.xml so that the library location and the library account password can be aligned.
Note Two, the URL of the <repository> element and the URL of the <snapshotRepository> element should be different. The first time I configured the above URL value to copy directly to the following URL, resulting in an error:
not transfer artifact Com.tony.aaa:webTT:war:1.0-20160124.105254-1 from/to Vineetmanohar-nexus (http://localhost:8081 is
2. Add a deployment plug-in
Use the Nexus-staging-maven-plugin plugin to make deployment smoother.
In the Pom.xml:
<Plugins> <plugin> <groupId>Org.sonatype.plugins</groupId> <Artifactid>Nexus-staging-maven-plugin</Artifactid> <version>1.5.1</version> <executions> <Execution> <ID>Default-deploy</ID> <Phase>Deploy</Phase> <Goals> <goal>Deploy</goal> </Goals> </Execution> </executions> <Configuration> <ServerID>Nexus</ServerID> <Nexusurl>http://localhost:8081/nexus/</Nexusurl> <skipstaging>True</skipstaging> </Configuration> </plugin> </Plugins>
3. Execute the deployment command
MVN clean deploy-dmaven.test.skip=true
When you're done, you should see something like this:
.... uploading:http://localhost:8081/nexus/content/repositories/snapshots/com/tony/aaa/webtt/ maven-metadata.xmluploaded:http://localhost:8081/nexus/content/repositories/snapshots/com/tony/aaa/webtt/ Maven-metadata.xml (275 B at 13.4 kb/sec) [INFO] * Bulk Deploy of locally gathered snapshot artifacts finished.[ INFO] Remote deploy finished with success. [INFO]------------------------------------------------------------------------[INFO] BUILD Success[info]-------- ----------------------------------------------------------------[INFO] Total time:1.689 s[info] finished at: 2016-01-24t21:12:28+08:00[info] Final Memory:16m/240m[info]----------------------------------------------------- -------------------
Indicates a successful deployment. You can then go to the Nexus to see results similar to the following:
At this point, the deployment is complete.
Resources:
Maven deploy to Nexus, Baelduang, MAVEN deployment tutorial
' Bad Request ' Error when deploying a artifact in Nexus
Getting started with Nexus Maven Repo Manager, Vineet Manohar ' s blog, a good tutorial that contains how to configure Nexus security
Repository Management with Nexus read the first three chapters to learn about the basic concept of Nexus
Maven Tutorial-tutorialspoint is a great tutorial to read about and use Maven in general.
Welcome to Apache maven, Apache Maven website, details about Maven can be found inside.
Deploy artifact to Nexus tutorials using Maven