Maven常用配置

0

<?xml version="1.0" encoding="UTF-8"?>
<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>D:\maven\repository</localRepository> -->
	<!-- 默认插件:<pluginGroups></pluginGroups> -->
	<!-- 配置代理:<proxies></proxies> -->

	<!-- 配置远程服务器授权信息 -->
	<servers>
		<!-- 资源对应:distributionManagement -> repository -> id -->
		<server>
			<id>sonatype_releases</id>
			<username>acgist</username>
			<password>password</password>
		</server>
		<server>
			<id>sonatype_snapshots</id>
			<username>acgist</username>
			<password>password</password>
		</server>
	</servers>
	
	<!--
		配置镜像服务器:
		优先级:repository(settings.xml) < repository(pom.xml) < mirror(settings.xml)
	-->
	<mirrors>
		<!--
			mirro匹配顺序:
				多个mirror按照id字母顺序进行排列(与编写的顺序无关)
				当第一个mirror找不到时不会继续查找下个镜像
				当第一个mirror无法链接才会尝试链接下个镜像
		-->
		<mirror>
			<id>repo0</id>
			<mirrorOf>central</mirrorOf>
			<name>aliyun</name>
			<url>https://maven.aliyun.com/repository/central</url>
		</mirror>
		<mirror>
			<id>repo1</id>
			<mirrorOf>central</mirrorOf>
			<name>Human Readable Name for this Mirror.</name>
			<url>http://repo1.maven.org/maven2/</url>
		</mirror>
		<mirror>
			<id>repo2</id>
			<mirrorOf>central</mirrorOf>
			<name>Human Readable Name for this Mirror.</name>
			<url>http://repo2.maven.org/maven2/</url>
		</mirror>
		<!-- mirrorOf配置*公司仓库 -->
		<mirror>
			<!-- 如果仓库需要权限访问id需要匹配server.id -->
			<id>nexus</id>
			<mirrorOf>*</mirrorOf>
			<name>local</name>
			<url>http://192.168.1.100:9999/nexus/content/groups/public/</url>
		</mirror>
	</mirrors>
	
	<!-- 配置构建方法 -->
	<profiles>
		<profile>
			<id>gpg</id>
			<properties>
				<gpg.executable>gpg</gpg.executable>
				<gpg.passphrase>password</gpg.passphrase>
			</properties>
		</profile>
		<profile>
			<id>nexus</id>
			<repositories>
				<repository>
					<id>nexus</id>
					<name>Public Repositories</name>
					<url>http://central</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
					</snapshots>
				</repository>
			</repositories>
			<pluginRepositories>
				<pluginRepository>
					<id>nexus</id>
					<name>Public Repositories</name>
					<url>http://central</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
					</snapshots>
				</pluginRepository>
			</pluginRepositories>
		</profile>
	</profiles>
	
	<activeProfiles>
		<activeProfile>gpg</activeProfile>
		<activeProfile>nexus</activeProfile>
	</activeProfiles>
	
</settings>