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)》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

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

Algorithms for Image Processing and Computer Vision

Algorithms for Image Processing and Computer Vision

Parker, J. R. / 2010-12 / 687.00元

A cookbook of algorithms for common image processing applications Thanks to advances in computer hardware and software, algorithms have been developed that support sophisticated image processing with......一起来看看 《Algorithms for Image Processing and Computer Vision》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

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

HTML 编码/解码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具