Maven 插件之maven-compiler-plugin

使用myeclipse创建maven项目,若不设置jdk默认使用的是1.5版本的,在myeclipse中设置了默认使用jdk的版本也没有用,需要在pom中配置编译插件才能修改,如下配置.

<build>
<finalName>commons</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>


也可以在setting.xml文件中配置


<profile>
 <id>jdk-1.7</id>
 <activation>
<activeByDefault>true</activeByDefault>
<jdk>1.7</jdk>
 </activation>
 <properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
 </properties>
</profile>


更多资料参见:http://maven.apache.org/

猜你喜欢

转载自blog.csdn.net/shui878412/article/details/53192114