Eclipse maven不在Java1.6中编译
如何强制maven编译1.6兼容源代码 我在eclipse中使用maven创建了web应用程序项目。将web.xml更改为使用3.0版本->然后更新配置,现在我无法启动tomcat。 我发现我必须强制maven编译与源代码1.6兼容的代码,并且我必须添加Eclipse maven不在Java1.6中编译,eclipse,maven,Eclipse,Maven,如何强制maven编译1.6兼容源代码 我在eclipse中使用maven创建了web应用程序项目。将web.xml更改为使用3.0版本->然后更新配置,现在我无法启动tomcat。 我发现我必须强制maven编译与源代码1.6兼容的代码,并且我必须添加 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin<
<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>
org.apache.maven.plugins
maven编译器插件
1.7
1.7
真的
真的
${env.JAVA\u HOME\u 7}/bin/javac
真的
但eclipse中的有效pom是不可编辑的
那么,是否有一个与eclipse兼容的maven或任何其他方式来强制maven编译源代码1.6版本?编辑:
只需使用Java1.6而不是1.7Java1.6
编辑2:
您的版本:
<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>
org.apache.maven.plugins
maven编译器插件
1.7
1.7
真的
真的
${env.JAVA\u HOME\u 7}/bin/javac
真的
应该是:
<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>
org.apache.maven.plugins
maven编译器插件
1.6
1.6
真的
真的
${env.JAVA\u HOME\u 7}/bin/javac
真的
编辑:
只需使用Java1.6而不是1.7Java1.6
编辑2:
您的版本:
<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>
org.apache.maven.plugins
maven编译器插件
1.7
1.7
真的
真的
${env.JAVA\u HOME\u 7}/bin/javac
真的
应该是:
<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>
org.apache.maven.plugins
maven编译器插件
1.6
1.6
真的
真的
${env.JAVA\u HOME\u 7}/bin/javac
真的
你就在那里。只需将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>
org.apache.maven.plugins
如果不需要,我也会避免额外的配置。您已经有了它。只需将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>
org.apache.maven.plugins
如果不需要,我也会避免额外的配置。只是为了澄清:
在项目POM中,您实际上并没有编写所有配置,而是覆盖(并最终向其中添加特性)默认配置
Eclipse中的“有效POM”向您显示了它的结果,因此这确实是不可编辑的
但是,如果在POM中添加一些配置(如其他答案中建议的waht),它将覆盖默认设置。它将按原样使用,并将显示在“有效POM”中。仅供澄清:
在项目POM中,您实际上并没有编写所有配置,而是覆盖(并最终向其中添加特性)默认配置
Eclipse中的“有效POM”向您显示了它的结果,因此这确实是不可编辑的
但是,如果在POM中添加一些配置(如其他答案中建议的waht),它将覆盖默认设置。它将按原样使用,并将显示在“有效POM”中