可能你当前使用的jdk是1.7+,但是每次Maven-> Update Project...之后,发现JRE Library又变成了JSE1.4,并且有可能不会报错,这种感觉就醉了。主要原因是每次Update时,它就会使用settings文件下的默认值。修改方法有两种(建议都使用)。
修改maven的默认jdk配置,找到maven的conf\setting.xml文件中找到jdk配置的地方,修改如下:
<profile> <id>jdk1.8</id> <activation> <activeByDefault>true</activeByDefault> <jdk>1.8</jdk> </activation> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> </properties> </profile>
修改项目中pom.xml文件,这样避免在导入项目时的jdk版本指定,打开项目中pom.xml文件,修改如下:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build>