高版本Java下Maven编译项目

我的软件环境:Java 1.8

Dynamic Web Module 3.1

来源: http://www.cnblogs.com/zhyp/p/5635700.html

记录一下,水平太菜,花费了半天时间。

pom.xml

<build>
    <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
            <source>1.7</source>
            <target>1.7</target>
        </configuration>
    </plugin>
    </plugins>
</build>
  1. Another way is to edit the project facet configuration file itself: org.eclipse.wst.common.project.facet.core.xml
  2. Change the dynamic web module version in this line to 3.1 – <installed facet=”jst.web” version=”3.0″/>
  3. And then Maven -> Update Project. You’ll find this file in the .settings directory within the Eclipse project

我的环境是Java1.8,在我修改项目的Project facets之后,就已经成为1、2两点所写的样子了。但是问题依旧,所以我的步骤是

  1. 修改pom.xml
  2. 将source和target改成1.8,如下所示
    <configuration>
    <source>1.8</source>
    <target>1.8</target>
    </configuration>
  3. 在项目的属性中选择Maven -> Update Project.

作者 龙飞