Maven 中设置工程的语言编译级别(compiler level)

栏目: 服务器 · 编程工具 · 发布时间: 8年前

内容简介:Maven 中设置工程的语言编译级别(compiler level)

Maven 工程缺省的情况下,它的编译级别(compiler level)是 JDK 1.5 这一级。对于现在的许多项目而言,这已经太老了,很多特性也不支持,所以,我们通常需要定义自己所需要的语言级别。

这点可以通过在 pom.xml 文件的 build 节点下的 plugins 节点下面增加一个 maven-compiler-plugin 来实现,具体如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<!-- ... 其它配置略 -->

	<build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.1</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

以上配置将语言级别设置为 Java 1.8,你也可以根据需要设为 1.7 或 1.6.

之后,在工程下:右键–maven–update project 来重新编译整个项目。(适用于 Eclipse)


以上所述就是小编给大家介绍的《Maven 中设置工程的语言编译级别(compiler level)》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Coming of Age in Second Life

Coming of Age in Second Life

Tom Boellstorff / Princeton University Press / 2008-04-21 / USD 29.95

The gap between the virtual and the physical, and its effect on the ideas of personhood and relationships, is the most interesting aspect of Boellstorff's analysis... Boellstorff's portrayal of a virt......一起来看看 《Coming of Age in Second Life》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换