问题描述
我刚刚在一个新的 ubuntu 系统上安装了 maven,其中包括 maven-compiler-plugin.我有一个以前构建良好的 java 项目,默认为 javac 源和目标 5 (jdk 1.5).但是,该项目现在正在尝试在新系统上使用 jdk1.3 进行编译.有没有一种简单的方法可以将系统配置为使用 >=jdk5 ?
I have just installed maven on an new ubuntu system, which includes the maven-compiler-plugin. I have a java project that was previously building fine, defaulting to a javac source and target of 5 (jdk 1.5). However, the project is now trying to compile using jdk1.3 on the new system. Is there an easy way to configure the system to use >=jdk5 ?
以下是系统的一些配置细节:
Here's some of the configuration details of the system:
$ java -version
java version "1.6.0_45"
$ dpkg -s maven
Package: maven
Status: install ok installed
Priority: optional
Section: java
Installed-Size: 1489
Maintainer: Ubuntu Developers <[email protected]>
Architecture: all
Version: 3.0.4-2
$ dpkg -s libmaven-compiler-plugin-java
Package: libmaven-compiler-plugin-java
Status: install ok installed
Priority: optional
Section: java
Installed-Size: 75
Maintainer: Ubuntu Developers <[email protected]>
Architecture: all
Source: maven-compiler-plugin
Version: 2.0.2-6
我检查了 maven-compiler-plugin-2.0.2.pom 文件,plexus-compiler-javac.originalVersion 等设置为 1.5.3.
I've checked the maven-compiler-plugin-2.0.2.pom file, and plexus-compiler-javac.originalVersion and others are set to 1.5.3.
我知道我可以通过在插件上下文中包含源/目标标记来在每个项目的基础上进行设置,但是我想将 maven-compiler 配置为默认为 jdk5 或更高版本,而不必跨大量项目.
I know I can set this on a per-project basis by including a source/target tag in a plugin context, but I'd like to configure maven-compiler to default to jdk5 or higher without having to do this across a large number of projects.
我该怎么做?
推荐答案
在旧版本的 maven-compiler 插件(如 2.0.2-6)中,源和目标的默认值是 1.3.使用至少 3.0 版本的 Maven 编译器插件将其恢复到原始行为,或者仅配置该插件以将源和目标设置为适当的值.
Default value for source and target was 1.3 in older versions of maven-compiler plugin (like 2.0.2-6).Use at least a 3.0 version of the Maven compiler plugin to get this back to the original behaviour, or just configure that plugin to get source and target to appropriate values.
这篇关于为 maven-compiler-plugin 设置默认 jdk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!