2013-02-11 46 views
1

编译如何强制Maven来编译1.6兼容的源行家并不在Java 1.6

我在Eclipse中的Maven做web应用程序项目。更改web.xml使用3.0版本 - >然后更新配置,现在我不能启动tomcat。 我发现我必须迫使Maven来编译源1.6兼容,并且我要补充

<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> 

但在日食有效POM是不可编辑

所以是有一个Maven与Eclipse兼容或者其他方式强制maven编译源码1.6版本?

+0

问题关闭 – simar 2013-02-11 08:46:05

回答

1

编辑:

只是使用,而不是1.7的Java 1.6。

EDIT2:

您的版本:

<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> 
</plugin> 

应该是:

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

只是为了澄清:

在项目POM,你实际上并没有写所有的configuraton,但覆盖(并最终增加功能)的默认配置。

Eclipse中的“Effective POM”显示了它的结果,所以确实这是不可编辑的。但是,如果您在POM中添加了一些配置(如在其他答案中建议使用waht),它将覆盖默认设置。它将按原样使用,并将显示在“有效POM”中。