SpringMVC------maven编译报错:Dynamic Web Module 3.0 requires Java 1.6 or newer

如图所示:

但是 Eclipse 明明已经将编译级别设置为 1.7:

这是由于你的 Maven 编译级别是 jdk1.5 或以下,而你导入了 jdk1.6 以上的依赖包:查看 Eclipse 的 Navigator 视图下该项目的 .classpath 文件:

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
  <attributes>
    <attribute name="maven.pomderived" value="true"/>
  </attributes>
</classpathentry>

解决办法:
使用 maven-compiler-plugin 将 maven 编译级别改为 jdk1.6 以上:

<build>
  <plugins>
    <!-- define the project compile level -->
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.3.2</version>
      <configuration>
        <source>1.7</source>
        <target>1.7</target>
      </configuration>
    </plugin>
  </plugins>
</build>

右击项目-》Maven-》Update Project

扫描二维码关注公众号,回复: 3099354 查看本文章
转载:
https://blog.csdn.net/defonds/article/details/47974269

猜你喜欢

转载自www.cnblogs.com/tianhengblogs/p/9614598.html