1. Introduction

Sometimes, when we make or build our SpringBoot app, we got this Exception:

[INFO] -------------------------------------------------------------
[ERROR] /Users/JavaProjects/springboot2-mvc/src/main/java/springboot2/mvc/PropertyLogger.java:[31,28] -source 1.5 do not support lambda expressions
  (please use -source 8 or bigger version to use lambda expression)
[ERROR] /Users/JavaProjects/springboot2-mvc/src/main/java/springboot2/mvc/PropertyLogger.java:[33,34] -source 1.5 do not support method reference
  (please use -source 8 or later to enable method reference)
[INFO] 2 errors 

2. Environments

  • 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: project

Check your Intellij Idea’s project module SDK configurations like this: project

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

mvn clean comiple

We get this:


4. Summary

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.