The Nexus deployment Maven repository has been introduced today to talk about releasing jars (projects) to the MAVEN.
This requirement is because the Web project uses the MAVEN library is a third-party, and the three-party this library is not stable (such as the version of the update, network interruption), although a library agent to download the index, but one day this third-party library services suddenly closed, and then the tragedy ...
This kind of tragedy has happened in my team, probably not a thorough understanding of the Maven library, or it may not be clear which jars are private. But how all good, out of the problem to solve, initially want to upload the missing jar to local maven, but not through its failure, in order to reduce the impact on development, and finally replaced a third-party library ...
Recently the problem has been solved, and suddenly found that it is so simple ...
First of all, the Sonatype Nexus OSS warehouse.
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M02/7F/73/wKioL1cfL9vR6Po4AAHXJxemGuA478.jpg "title=" 1.jpg " alt= "Wkiol1cfl9vr6po4aahxjxemgua478.jpg"/>
Warehouse Type:
Group: Warehouse groups. The selected warehouse can be added to the warehouse group
Hosted: Host. Self-created files are placed under this type
Proxy: Agent.
Virtual: Dummy.
Warehouse Properties:
Policy
Release: Released, representing both stable versions
Snapshot: Snapshot, representing development version
Download remote Indexes: Default to False
Default local Storage Location: defaults on-Premises directory
Override Local Storage Location: re-stored locally
Default Library:
Central: The warehouse agent maven centralized Repository, whose policy is release, will only download and cache the release build artifacts in the central repository.
Releases: This is a host-type warehouse with a policy of releases, which is used to deploy release build artifacts within your organization.
Snapshots: This is a host-type warehouse with a policy of snapshot, which is used to deploy snapshot version artifacts within the organization.
3rd party: This is a host-type warehouse with policy release, which is used to deploy components that cannot be obtained from a public warehouse.
Apache Snapshots: This is a strategy for the snapshots Agent repository, which is used to proxy the snapshot version artifacts of the Apache Maven repository.
Codehaus snapshots: This is a broker repository with policy snapshots that is used to proxy the snapshot version artifacts for Cohehaus maven repositories. http://morrowind.blog.51cto.com/addblog.php
Sonatype repositories: This is a broker repository with policy release, which is used to proxy the snapshot version artifacts of the Sonatype maven warehouse.
Central M1 Shadow: A component-mirrored warehouse used to provide a release version of the M1 format in a centralized warehouse
Publish to Maven Central warehouse
Nexus uploads:
Select Releases warehouse, in the "Artifact Upload" property card, select "Select artifacts (s) to Upload" upload the package that needs to be published, "GAV Definition" Select the Pom file, If there is no Pom file, specify the package coordinates manually after selecting Gav parameters.
to deploy artifacts to a nexus using Maven:
Select the Releases/snapshots warehouse, and in the Configuration property card, confirm that the Deployment Policy attribute is allow redeploy
Enable Deployment user, nexus Default has three users, where Deployment users are used to deploy projects
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7F/74/wKioL1cfQqWDZbLJAABPRueobME621.png "title=" 2.png "alt=" Wkiol1cfqqwdzbljaabprueobme621.png "/>
Deployment User Default password is deployment123, right-click menu can modify or reset password
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7F/77/wKiom1cfQhqBI8j4AABVC8tMO0I077.png "title=" 3.png " alt= "Wkiom1cfqhqbi8j4aabvc8tmo0i077.png"/>
Configure the deployment warehouse for release and snapshot versions in Pom.xml, where the IDs are unique and the URLs correspond to the repository Path for the releases and snapshots warehouses in the database, respectively:
650) this.width=650; "src=" Http://image.mamicode.com/info/201604/20181018135245762821.png "style=" margin:0px; padding:0px;border:0px; "/>
<uniqueVersion> Indicates whether a build number with a timestamp is assigned to the snapshot version, with the following effect:
650) this.width=650; "src=" Http://image.mamicode.com/info/201604/20181018135245863400.png "style=" margin:0px; padding:0px;border:0px; "/>
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none;background-color:rgb ( 245,245,245); "/>
<distributionManagement> < Snapshotrepository> <id> User-snapshot</id> <name> user porject snapshot</name> <url>http://localhost:8081/nexus/content/repositories/snapshots/</url> <uniqueVersion>true</uniqueVersion> </snapshotRepository> <repository> <id >user-release</id> <name >user porject release</Name> <url>http://localhost : 8081/nexus/content/repositories/releases/</url> </ Repository> </distributionmanagement>
The Nexus's repository is read-only for anonymous users. To be able to deploy artifacts, we also need to configure the validation information in Settings.xml:
<servers> <server> <id>user-release</id> <username>deployment</username> <password>deployment123</ password> </server> <server> <id >user-snapshot</id> < username>deployment</username> <password>deployment123</password> </ Server> &nbsP; ... </servers>
Where the ID of the service in the authentication information should match the ID of repository in the Pom.
This allows Maven to be automatically assigned to the Nexus. The command is as follows:
MVN Clean Deploy-dmaven.test.skip=true
You can also right-click Pom.xml, Run as->2 Maven build
650) this.width=650; "src=" Http://image.mamicode.com/info/201604/20181018135246013781.png "alt=" 302309511055471. PNG "/>
Once the release is successful, you can see it in the repository:
650) this.width=650; "src=" Http://image.mamicode.com/info/201604/20181018135246372157.png "alt=" 302311224183467. PNG "/>
Reference: http://www.cnblogs.com/luotaoyeah/p/3817465.html
Recommended: Maven's definitive guide or maven combat
Release maven to Nexus Central Warehouse