jar jar package and install third-party package to the local development of remote repository (PW)

Install third-party jar package to the remote repository (PW)

1, add a login settings in the configuration file, PW login information to third parties

<servers>
	<server>
		<id>releases</id>
		<username>admin</username>
		<password>admin123</password>
	</server>
	<server>
		<id>snapshots</id>
		<username>admin</username>
		<password>admin123</password>
	</server>
</servers>
注:用户名和密码填写自己的实际内容

2, into the jar package directory run

mvn deploy:deploy-file -Dfile=jar包路径 -DgroupId=jar包的groupId -DartifactId=jar包的artifactId -Dversion=jar包版本号 -Dpackaging=jar -Durl=私服地址 -DrepositoryId=私服Id

Installation of local development jar package to the remote repository (PW)

Jar deployment package to the remote repository consists of two parts: a remote repository certification, deployment jar package to the remote repository
1, most remote repository can be accessed without authentication, but sometimes for security reasons, we need to provide authentication information access to some remote repository. At this time, in order to allow access to the repository content Maven, you need to configure the authentication information.

Configuring authentication information, and configuration information in different warehouses, warehouse information can be configured directly in the POM file, but the authentication information must be configured in settings.xml file because POM tend to be submitted to the code repository accessible by all members, and settings.xml generally in the machine. Therefore, in the settings.xml configuration more secure authentication information.

Configuring authentication $ {MAVEN_HOME} /conf/settings.xml file

<servers>
	<server>
		<id>releases</id>
		<username>admin</username>
		<password>admin123</password>
	</server>
	<server>
		<id>snapshots</id>
		<username>admin</username>
		<password>admin123</password>
	</server>
</servers>
注:用户名和密码填写自己的实际内容

2, a major role of PW is to deploy a third-party components, including the internal organization of the generated artifacts and some of the components can not be obtained directly from the outside of the warehouse. Whether it is daily generated in the development of components, or the official release of members, need to be deployed to the warehouse for other team members.

In addition to Maven can compile, test, package of the project, will also be deployed to build the warehouse project generates. First, you need to write pom.xml file for the project. Configuring distributionManagement elements see below.

Note: repository where id required first step and in the name of keeping the server id

<project>
...
    <distributionManagement>
        <repository>
            <!--repository里的id需要和第一步里的server id名称保持一致-->
            <id>releases</id>
            <!--仓库名称-->
            <name>Releases</name>
            <!--私服仓库地址-->
            <url>http://xxxx:8081/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <name>Snapshot</name>
            <url>http://xxxx:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
...
</project>

distributionManagement contains repository and snapshotRepository sub-elements, the former represents the release version of the warehouse building, which represents a snapshot version of the warehouse. These two elements need to configure the id, name and url, id that uniquely identifies a remote repository, name is to facilitate people to read, url indicates the address of the warehouse.

After the configuration is correct, the command line to run mvn clean deploy, Maven will build the project output component corresponding to the configuration deployed to a remote repository, the current version is a snapshot version if the project is to deploy a snapshot version of the address of the warehouse, otherwise deployed to release version of the address of the warehouse.

More knowledge See: https: //github.com/Lzycug/CommonToolsRepository.git

Released eight original articles · won praise 6 · views 357

Guess you like

Origin blog.csdn.net/lzycug/article/details/103843358