Overview
After the latest version of IntelliJ idea was upgraded, a lot of errors often occur when you compile or package the MAVEN project, and the wrong hints are basically syntax errors caused by the incorrect JDK version. At first not too much attention, thought is the default configuration has not been modified. So the Java compiler and project in the settings
The language level in the settings is changed to its own version, such as jdk1.7, and the problem is temporarily resolved. However, the next time you compile or package the same problem (it turns out that it happened because of changes to the Pom file). cause Analysis
After being checked, it turns out that the root cause of this problem is that no JDK versions are configured in MAVEN's Pom.xml file. When the JDK version is not configured, the Java compiler and language level will automatically revert to the original default 1.5 version once the Pom file has changed. Solution
Add the Maven-compiler-plugin plug-in to the Pom file and specify the JDK version that JDK uses to solve the problem above. The Maven-compiler-plugin configuration also takes effect on both the Java compiler and language level.
Configuration content is as follows:
<build>
<plugins>
<plugin>
<groupid>org.apache.maven.plugins</groupid >
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</ configuration>
</plugin>
</plugins>
</build>
I now use the JDK7, so configure 1.7. If you encounter a similar problem, you can configure the appropriate version number according to the specific JDK version you are using.