maven setting.xml配置模板

记录一个简单的代理模板配置:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<!--设置本地仓库 -->
	<localRepository>\resp</localRepository>

	<pluginGroups>
	</pluginGroups>

	<!--设置私库认证信息 -->
	<servers>
		<server>
			<id>nexus</id>
			<username>xxx</username>
			<password>xxx</password>
		</server>
		<server>
			<id>nexus-releases</id>
			<username>xxx</username>
			<password>xxx</password>
		</server>
		<server>
			<id>nexus-snapshots</id>
			<username>xxx</username>
			<password>xxx</password>
		</server>
		<server>
			<id>maven-releases</id>
			<username>xxx</username>
			<password>xxx</password>
		</server>
		<server>
			<id>maven-snapshots</id>
			<username>xxx</username>
			<password>xxx</password>
		</server>
	</servers>

	<!--设置私库mirror 表示maven所有的请求都由nexus来处理 -->
	<mirrors>
		<mirror>
			<id>nexus</id>
			<mirrorOf>*</mirrorOf>
			<name>Nexus Mirror.</name>
			<url>http://xxx.xxx.xxx.xxx:8081/repository/maven-public/</url>
		</mirror>
		<!--<mirror>
			<id>nexus-aliyun</id>
			<mirrorOf>central</mirrorOf>
			<name>Nexus aliyun</name>
			<url>https://maven.aliyun.com/repository/public</url>
		</mirror>-->
	</mirrors>

	<!--设置maven私库信息 -->
	<profiles>
		<profile>
			<id>nexus</id>
			<!--
			 依赖与插件为什么需要分开配置?
			依赖与插件的职责不同:
			依赖:项目运行时所需的第三方库或内部模块。
			插件:Maven构建过程中执行任务的工具(如编译、打包、测试)。
			更新策略可能不同:
			依赖可能需要稳定的发布版(<updatePolicy>never</updatePolicy>),而插件可能需要频繁更新(always)。
			例如,快照版依赖可能每天更新一次(daily),而插件可能需要每次检查更新(always)。
			-->
			<!---定义依赖仓库-->
			<repositories>
				<repository>
				    <!--仓库的唯一标识符(如nexus),用于在Maven配置中引用该仓库-->
					<id>nexus</id>
					<name>Nexus</name>
					<!--仓库的地址(如Nexus服务器的URL)。-->
					<url>http://xxx.xxx.xxx.xxx:8081/repository/maven-public/</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
						<!-- 
						always:每次构建都检查更新。
						daily:每天检查一次(默认)。
						interval:X:每X分钟检查一次。
						never:从不检查。
						-->
						 <updatePolicy>always</updatePolicy>
					</snapshots>
				</repository>
			</repositories>
			<!--定义插件仓库
			指定Maven在构建项目时,从哪些远程仓库下载Maven插件(如maven-compiler-plugin、maven-surefire-plugin等)。
			-->
			<pluginRepositories>
				<pluginRepository>
					<id>nexus</id>
					<name>Nexus</name>
					<url>http://xxx.xxx.xxx.xxx:8081/repository/maven-public/</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
						<!-- 
						always:每次构建都检查更新。
						daily:每天检查一次(默认)。
						interval:X:每X分钟检查一次。
						never:从不检查。
						-->
						 <updatePolicy>always</updatePolicy>
					</snapshots>
				</pluginRepository>
			</pluginRepositories>
		</profile>
	</profiles>

	<!--激活私库信息的配置 -->
	<activeProfiles>
		<activeProfile>nexus</activeProfile>
	</activeProfiles>
</settings> 

很高兴能为您解答,以下是 Maven 3.8.1 的 setting.xml 模板: ```xml <?xml version="1.0" encoding="UTF-8"?> <!-- | Licensed to the Apache Software Foundation (ASF) under one | or more contributor license agreements. See the NOTICE file | distributed with this work for additional information | regarding copyright ownership. The ASF licenses this file | to you under the Apache License, Version 2.0 (the | "License"); you may not use this file except in compliance | with the License. You may obtain a copy of the License at | | http://www.apache.org/licenses/LICENSE-2.0 | | Unless required by applicable law or agreed to in writing, | software distributed under the License is distributed on an | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | KIND, either express or implied. See the License for the | specific language governing permissions and limitations | under the License. --> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository>${user.home}/.m2/repository</localRepository> <interactiveMode>true</interactiveMode> <offline>false</offline> <servers> <!-- 配置私有仓库的认证信息 --> <server> <id>my-private-repo</id> <username>myusername</username> <password>mypassword</password> </server> </servers> <mirrors> <!-- 这里是阿里云的 Maven 镜像 --> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> <profiles> <profile> <id>my_profile</id> <repositories> <!-- 私有仓库 --> <repository> <id>my-private-repo</id> <url>http://my.private.repo/url</url> </repository> <repository> <id>central</id> <url>https://repo1.maven.org/maven2</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> <!-- 这里是阿里云的 Maven 镜像 --> <repository> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <snapshots> <enabled>false</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository> </repositories> </profile> </profiles> <activeProfiles> <activeProfile>my_profile</activeProfile> </activeProfiles> </settings> ``` 希望能够帮到您,如果还有其他问题,请随时联系我。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值