maven不在java中编译1.6 [英] maven does not compile in java 1.6

查看:101
本文介绍了maven不在java中编译1.6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何强制maven编译1.6兼容源

how to force maven to compile 1.6 compatible source

我在eclipse中用maven制作了web应用程序项目。更改web.xml以使用3.0版本 - >然后更新配置,现在我不能启动tomcat。
我发现我必须强制maven编译源1.6兼容,我必须添加

i made web-app project with maven in eclipse. change web.xml to use 3.0 version -> then update configuration and now i cant start tomcat. I found that i have to force maven to compile source 1.6 compatible and i have to add

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
 <configuration>
    <source>1.7</source>
    <target>1.7</target>
    <showDeprecation>true</showDeprecation>
    <showWarnings>true</showWarnings>
    <executable>${env.JAVA_HOME_7}/bin/javac</executable>
    <fork>true</fork>
</configuration>

但eclipse中有效的pom是不可编辑

but effective pom in eclipse is not editable

是否有一个与eclipse兼容的maven或任何其他方式强制maven编译源1.6版本?

so is there a maven compatible with eclipse or any other way to force maven to compile source 1.6 version?

推荐答案

你有它。只是放1.6而不是1.7:

You have it there. Just put 1.6 instead of 1.7:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.0</version>
    <configuration>
      <source>1.6</source>
      <target>1.6</target>
    </configuration>
  </plugin>

请参阅: http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source- and-target.html

如果不需要,我也会避免额外的配置。

I would also avoid additional configuration if not needed.

这篇关于maven不在java中编译1.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆