maven不能在java 1.6中编译

sim*_*mar 1 eclipse maven

如何强制maven编译1.6兼容源

我在eclipse中用maven制作了web-app项目.将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>
Run Code Online (Sandbox Code Playgroud)

但日食中的有效pom是不可编辑的

所以有没有maven兼容eclipse或任何其他方式强制maven编译源1.6版本?

wem*_*emu 5

你有它.只需1.6而不是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>
Run Code Online (Sandbox Code Playgroud)

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

如果不需要,我也会避免其他配置.