0

When I load my Maven, Java project in Visual Studio Code, I get this error:

Lambda expressions are allowed only at source level 1.8 or above Java(1610613381)

However, my pom.xml has my Java source level set to level 1.8 or above. For example:

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
  </properties>

And mvn compile works just fine.

What is going on?

Wallace Kelly
  • 15,565
  • 8
  • 50
  • 71

1 Answers1

0

In my case, I was using VS Code to open a parent folder of my Java project. That is, my pom.xml file was not in the folder that was opened by Visual Studio Code -- it was in the child folder which contained my Java project. When I instead open the Java project folder, the editor does not complain.

Wallace Kelly
  • 15,565
  • 8
  • 50
  • 71
  • There must be more going on than I understand. Today, I cannot reproduce the problem. – Wallace Kelly May 26 '23 at 17:43
  • glad to know you've found the solution to resolve this issue! Please consider accepting it as the answer to change its status to Answered. See [can I answer my own question..](https://stackoverflow.com/help/self-answer), Just a reminder :) – JialeDu May 29 '23 at 01:42