Use the mvn deploy command to upload the jar package to the nexus private server

Use the mvn deploy command to upload the jar package to the nexus private server

Before using the command, you must change the configuration address of maven to the private server address
. 1. Configure the setting.xml file.
Because nexus requires login operation, of course, you can configure to avoid login

  <servers>
    <server>
        <id>maven-releases</id>
        <username>admin</username>
        <password>k0al7410</password>
    </server>
    <server>
        <id>maven-snapshots</id>
        <username>admin</username>
        <password>k0al7410</password>
    </server>
    <server>
        <id>kiam.xa.snapshot</id>
        <username>admin</username>
        <password>k0al7410</password>
    </server>
    <server>
        <id>kiam.xa.release</id>
        <username>admin</username>
        <password>k0al7410</password>
    </server>
  </servers>
<!--配置maven私服地址-->
  <mirrors>
     <mirror>
	<id>nexus</id>
	<name>nexus repository</name>
	<url>http://10.2.0.3:8081/repository/kiam.xa.group/</url>
	<mirrorOf>central</mirrorOf>        
     </mirror>
  </mirrors>

  <profiles>
  <profile>
        <id>nexus</id>
        <repositories>
            <repository>
                <id>maven-snapshots</id>
                <name>maven-snapshots</name>
                <url>http://10.2.0.3:8081/repository/maven-snapshots/</url>
                <releases>
                    <enabled>false</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
            <repository>
                <id>maven-releases</id>
                <name>maven-releases</name>
                <url>http://10.2.0.3:8081/repository/maven-releases/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
            </repository>
        </repositories>
    </profile>
  </profiles>

2. Upload command format

mvn deploy:deploy-file 
       -DgroupId=kl.iam  
       -DartifactId=common 
       -Dversion=1.0-SNAPSHOT 
       -Dpackaging=jar 
       -Dfile=D:/sx_urm/backend/uim/backend/lib/common-1.0-SNAPSHOT.jar -Durl=http://10.2.0.3:8081/repository/maven-snapshots/ -DrepositoryId=maven-snapshots
参数解释:
     -DgroupId=jar包的组名
     -DartifactId=jar包名称
     -Dversion=jar包版本
     -Dfile=jar包绝对路径
     -DrepositoryId=yang        nexus服务器上仓库的名称

result:

Note: How to get an accurate version of a jar package?
Unzip the package, you will find a file called MANIFEST.MF, this file has version information describing the package.
For example, Manifest-Version: 1.0 can know the version of the package.

Guess you like

Origin blog.csdn.net/weixin_45785469/article/details/109274474