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

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

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

查看所有标签

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

How to Think About Algorithms

How to Think About Algorithms

Jeff Edmonds / Cambridge University Press / 2008-05-19 / USD 38.99

HOW TO THINK ABOUT ALGORITHMS There are many algorithm texts that provide lots of well-polished code and proofs of correctness. Instead, this one presents insights, notations, and analogies t......一起来看看 《How to Think About Algorithms》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具