web123456

Maven learns sixth to upload packages using mvn deploy command

mvn:deploy is executed in an integrated or publishing environment, copying the final version of the package to a remote repository, so that other developers or projects can share it. Take the third party that passes ojdbc14 to nexus as an example

 

1 Configuration

Because nexus requires login operation, of course, you can configure it without login, which is a later story. In <servers></servers>

<server>   
<id>thirdparty</id>   
<username>admin</username>
<password>admin123</password>   
</server>

Of course, if you want to upload a package to another repository, you can follow this example:

<server>   
<id>central</id>   
<username>admin</username>   
<password>admin123</password>   
</server>

If the return code is: 401 error is returned when deploying, you need to verify the user or the information you have verified is incorrect.

 

2 cmd input command

mvn deploy:deploy-file -DgroupId= -DartifactId=ojdbc14 -Dversion=10.2.0.4.0 -Dpackaging=jar -Dfile=E:\ -Durl=http://localhost:9090/nexus-2.2-01/content/repositories/thirdparty/ -DrepositoryId=thirdparty

DgroupId and DartifactId constitute the coordinates of the jar package, and the project relies on these two attributes to position it. It's okay to name it yourself.

Dfile indicates the absolute path to the jar package that needs to be uploaded.

To see the location of the repository on the Durl private server, open the nexus > repositories menu and you can see the path.

The representation id of the DrepositoryId server can be seen in the configuration of nexus.

Dversion represents version information,How to get the exact version of a jar package?

Unzip the package and you will find a file called, which has information describing the version of the package.

For example, Manifest-Version: 1.0 can know the version of this package.

After the upload is successful, click on the 3rd party repository in the nexus interface to see this package.

 

3 Some questions

When typing this command, sometimes you will see a prompt that you need a POM file, but you do not need a pom file to upload the package. The most likely possibility is that you typed a wrong statement such as an extra space and a new line. The solution is to patiently type the command again.