When using MAVEN to develop a project, module A may be dependent on module B's Jar package, and if two modules are in a project, simply add the dependency information of Module B to module A's pom file, and module A can load Module B's Jar package. However, if module A and Module B are in different projects or even developed by different engineers, then you need to deploy module B to the remote repository, and module A can download the jar package for module B by configuring the address of the remote repository in the Pom file.
There are usually two types of remote warehouses that are allowed to be uploaded: snapshots and releases, respectively, the snapshot and stable warehouses. The snapshot version of the warehouse is used to store the unstable development package, and the stable version of the warehouse is used for stable packages.
Configure the following in the local maven settings.xml:
<Server> <ID>Snapshots</ID> <username>Your user name</username> <Password>Your password.</Password></Server> <Server> <ID>Releases</ID> <username>Your user name</username> <Password>Your password.</Password></Server>
Open cmd and position it to the folder of the jar package you want to upload, like enter the following command:
MVN deploy:deploy-file -dgroupid=com.test-dartifactid=service-api-dversion=2.5. 0-snapshot-dpacckaging=jar-dfile=service-api-2.5. 0-snapshot.jar-drepositoryid=snapshots-durl=http://www.hello.com:8787/archiva/ Repository/snapshots
Note that –dversion,-drepositoryid,-durl are corresponding, such as the version is snapshot, the warehouse ID should also be the ID of the snapshot warehouse, warehouse address also need to fill in the URL of the snapshot warehouse.
If the cmd current path and the path of the jar package are in the same folder,-dfile writes the file name directly, if it is not in the same directory, you need to write the absolute path of the file after-dfile.
Deploy the jar package to the remote MAVEN repository