Upload and download the project to the private server in maven

Upload the code project of maven-dao layer to private server

Configuration

Step 1: You need to configure the maven environment on the computer where the ssm_dao project is deployed on the client side, and modify settings.xml

File, configure the user and password for connecting to the private server.
This user name and password are used for private server verification, because the private server needs to know whether the uploaded account and password are
consistent with the account and password in the private server .
It is to modify the configuration file in the maven project installed by yourself, and add the following code in the servers tab.
If your password has not been modified, it is the default
username admin
password admin123

<server>
		<id>releases</id>
		<username>admin</username>
		<password>admin123</password>
		</server>
		<server>
		<id>snapshots</id>
		<username>admin</username>
		<password>admin123</password>
	</server>

releases connect to release version project warehouse
snapshots connect to test version project warehouse

Step 2: Configure pom.xml in the code of the maven-dao layer of the project.

Configure the address of the private server warehouse. The company's own jar package will be uploaded to the private server host warehouse. According to the version number of the project, the host warehouse
to upload to is determined. If the version is release, upload to the private server release warehouse. If the version is
snapshot, then Upload to the snapshot warehouse of the private server and
add the following paragraph

<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>

Note: pom.xml corresponds to the settings.xml configuration here!

test

1. Start nexus first.
2. Execute the deploy command
to the ssm_dao project. According to the version definition in the pom.xml of this project, decide which warehouse to publish to. If the version is defined as snapshot,
check the snapshot warehouse of nexus after executing deploy. If the version is defined as release, then the project Will be released to nexus
release warehouse, this project will be released to snapshot warehouse:

Download the jar package from the private server, such as the required dao layer code

     Before configuring nexus, if the local warehouse is not available, go to the central warehouse to download. Usually a private server server is deployed in the local area network in the enterprise. If there is a private server local project, first go to the local warehouse to find the jar, if not found, connect to the private server and download it from the private server. Jar package, if the private server does not have a jar package, the private server also acts as a proxy server to download the jar package from the central warehouse. The advantage of this is that on the one hand, the private server’s dependence on the company’s project is managed by the jar package, and on the other hand, the download speed is increased. The speed of the package is much faster than the speed of the project connecting to the central warehouse.

Configure the warehouse in setting.xml in maven

Configure the following code in the profiles tab

<!-- 下载jar包配置 -->
	<profile> 
		<!--profile的id -->
		<id>dev</id>
		<repositories>
			<repository> <!--仓库id,repositories可以配置多个仓库,保证id不重复 -->
				<id>nexus</id> <!--仓库地址,即nexus仓库组的地址 -->
				<url>http://localhost:8081/nexus/content/groups/public/</url> <!--是否下载releases构件 -->
				<releases>
					<enabled>true</enabled>
				</releases> <!--是否下载snapshots构件 -->
				<snapshots>
					<enabled>true</enabled>
				</snapshots>
			</repository>
		</repositories>
		<pluginRepositories> <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
			<pluginRepository> <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
				<id>public</id>
				<name>Public Repositories</name>
				<url>http://localhost:8081/nexus/content/groups/public/</url>
			</pluginRepository>
		</pluginRepositories>
	</profile>

Add activeProfiles after the profiles tag

<activeProfiles>
		<activeProfile>dev</activeProfile>
	</activeProfiles>

You can download it

Guess you like

Origin blog.csdn.net/he1234555/article/details/113853029