Use maven to automatically package the project and publish it to the local repository

Students who know maven know that the maven release command is: mvn deploy, but errors such as 401, 403, and 405 will appear when publishing, all of which are caused by incorrect local configuration environment.

 

Here's a rundown of what I've done successfully:

 

1. Before executing mvn deploy, you need to configure the maven setting file. This setting can be the setting of the client, or the setting of the server, that is, the setting under conf in maven_home. You need to add the username and password for logging in to the local warehouse nexus, as follows:

<servers>
       <server> 
              <id>releases</id> 
                <username>admin</username> 
                <password>admin123</password>  
       </server>  

</servers>

 

2. Add in the pom of the project:

 

<distributionManagement>
      <repository>
               <id>releases</id>
               <url>http://127.0.0.1:8081/nexus/content/repositories/releases/</url>
      </repository>
 </distributionManagement>

 

 

 

3. Finally, you can use [mvn deploy] to publish the jar to the local warehouse.

 

Note: The id in the server here corresponds to the id in the repository.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327086346&siteId=291194637