maven本地配置及pom.xml配置解决未指定jdk版本错误

一、maven本地配置

<?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>E:\MavenRepo\repository</localRepository>
	<!-- 是否使用本地仓库(先从本地查找依赖,如果没有再使用远程仓库) -->
	<interactiveMode>true</interactiveMode>
	<!-- 是否离线(如果为true则只从本地仓库查找依赖) -->
	<offline>false</offline>
	
	<pluginGroups>
		
	</pluginGroups>

	<proxies>
		
	</proxies>

	<servers>
		
	</servers>

	<mirrors>
		
		<mirror>
			<id>alimaven</id>
			<name>aliyun maven</name>
			<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
			<mirrorOf>central</mirrorOf>
		</mirror>
		<mirror>
			<id>ali-maven</id>
			<mirrorOf>central</mirrorOf>
			<name>aliyun maven</name>
			<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
		</mirror>
		<mirror>
			<id>central</id>
			<name>Maven Repository Switchboard</name>
			<url>http://repo1.maven.org/maven2/</url>
			<mirrorOf>central</mirrorOf>
		</mirror>
		<mirror>
			<id>repo2</id>
			<mirrorOf>central</mirrorOf>
			<name>Human Readable Name for this Mirror.</name>
			<url>http://repo2.maven.org/maven2/</url>
		</mirror>
		<mirror>
			<id>ibiblio</id>
			<mirrorOf>central</mirrorOf>
			<name>Human Readable Name for this Mirror.</name>
			<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
		</mirror>
		<mirror>
			<id>jboss-public-repository-group</id>
			<mirrorOf>central</mirrorOf>
			<name>JBoss Public Repository Group</name>
			<url>http://repository.jboss.org/nexus/content/groups/public</url>
		</mirror>
		<!-- 中央仓库在中国的镜像 -->
		<mirror>
			<id>maven.net.cn</id>
			<name>oneof the central mirrors in china</name>
			<url>http://maven.net.cn/content/groups/public/</url>
			<mirrorOf>central</mirrorOf>
		</mirror>
		<!-- apache -->
		<mirror>
			<id>apache</id>
			<name>apache mirrors</name>
			<url>http://repository.apache.org/content/groups/public/</url>
			<mirrorOf>central</mirrorOf>
		</mirror>
		<mirror>
			<id>apache-snapshots</id>
			<name>apache-snapshots-mirrors</name>
			<url>http://repository.apache.org/content/groups/snapshots/</url>
			<mirrorOf>snapshots</mirrorOf>
		</mirror>
	</mirrors>

	<profiles>
	<!-- 指定jdk版本,解决编译或打包时出现jdk版本未指定错误 -->
		<profile>
			 <id>custom-compiler</id>  
            <properties>  
                <JAVA8_HOME>D:\Java\jdk1.7.0_80</JAVA8_HOME>
                <JAVA7_HOME>D:\Java\jdk1.8.0_121</JAVA7_HOME>
                <JAVA6_HOME>D:\Java\jdk1.6.0_43</JAVA6_HOME>
            </properties>  
		</profile>
	</profiles>

	<activeProfiles>  
        <activeProfile>custom-compiler</activeProfile>  
	</activeProfiles>  
</settings>

二、maven项目的pom.xml配置

如下面配置,采用jdk7作为项目默认jdk编译版本

<build>
		<pluginManagement>
			<plugins>
				<plugin>
				<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-compiler-plugin</artifactId>
					<version>3.6.2</version>
					<configuration>
						<source>1.7</source>
						<target>1.7</target>
						<compilerVersion>1.0</compilerVersion>
						<verbose>true</verbose>  
        				<fork>true</fork>  
       					<executable>${JAVA7_HOME}/bin/javac</executable>  
					</configuration>
				</plugin>
				
			</plugins>
		</pluginManagement>
	</build>











猜你喜欢

转载自blog.csdn.net/eguid/article/details/78291497