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>