Maven uses deploy to upload jar packages to remote libraries

1. Environmental preparation

First of all, you need to install maven in the local environment, and configure the environment variables. For the specific installation and configuration methods, please refer to my previous article: Maven installation and environment configuration - http://blog.csdn.net/roy_70/article /details/63262370

2. Configure remote library authentication

After the installation is complete, you need to configure the address, user and password (if authentication is required) for the remote upload library in ./conf/setting.xml:

<servers>
    <server>
      <id>roy_privrepository_snapshots</id>
      <username>roy</username>
      <password>123456</password>
    </server>
</servers>
  • As above, the repository id is roy_privrepository_snapshots, username and password.

3. Upload using the deploy command

Open the cmd command prompt, mvn install is to install the jar package to the local library, mvn deploy is to upload the jar package to the remote server, install and deploy will first build and check by themselves, if the jar package is confirmed to be OK, you can use -Dmaven. The test.skip=true parameter skips compilation and testing. 
The full command is:

mvn deploy:deploy-file -Dmaven.test.skip=true -Dfile=D:\MvnProject\service-mvn-1.0.0.jar -DgroupId=pri.roy.mvn.test -DartifactId=mvn-api -Dversion=1.0.0-SNAPSHOT -Dpackaging=jar -DrepositoryId=roy_privrepository_snapshots -Durl=http://10.4.71.144:9090/repository/roy_privrepository_snapshots/
  • The meaning of each parameter is:
-Dmaven.test.skip=true                              //跳过编译、测试
-Dfile=D:\MvnProject\service-mvn-1.0.0.jar          //jar包文件地址,绝对路径
-DgroupId=pri.roy.mvn.test                          //gruopId--pom坐标,自定义
-DartifactId=mvn-api                                //artifactId--pom坐标,自定义
-Dversion                                           //版本号
-Dpackaging                                         //打包方式
-DrepositoryId                                      //远程库服务器ID
-Durl                                               //远程库服务器地址
  • Notice: 

The command has only one line, each parameter is separated by spaces, and the pom file is automatically generated. 
As shown in the figure, the success prompt appears, which means the upload is successful. 
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325292036&siteId=291194637