springboot-How to solve compilation error of springboot2 apps
Sometimes, when we make or build our SpringBoot app, we got this Exception:
- SpringBoot 2.x
3. The solution
3.1 Check your Intelli Idea configurations
Check your Intellij Idea’s project source’s language level configurations like this:
Check your Intellij Idea’s project module SDK configurations like this:
3.2 solution 1: Add build plugin to your pom
By default, Maven 3 uses JDK 1.5 to compile the project, which is very old. Fortunately, Maven comes with a maven-compiler-plugin, which tells Maven to compile the project source with a specified JDK version.
Add this build plugin to your project:
3.3 solution 2: Add properties to your pom
Alternatively, you can add these properties to your pom :
3.3 Rebuild your project
We get this:
You can see that maven use the jdk 1.5 to build springboot apps by default, you can change this by use the maven-compiler-plugin or add maven.compiler properties to your pom.