Fix Error:java: Invalid source release: xxx (latest - 2023). e.g. Invalid source release: 12, Invalid source release: 17

1. Reproduce the error


Today we are going to test camundathe workflow, so create a new spring boot camundaproject, as shown in the following figure:

insert image description here

But when starting, the following error is reported:

insert image description here

2. Analysis errors


Error description: Error:java: 无效的源发行版: 12.

When using ideathe running project, if an error is reported: Invalid source distribution: XXX.

This is because the version numbers of the version ideaset jdkand the version of the project being run do not match.jdk

If the project jdkversion is 12and ideathe environment setting jdkversion is 1.8, an error will be reported.

3. Fix bugs

  1. Click ideain Project Structure, or use Ctrl + Alt + Shitf + Sshortcut keys, as shown in the figure below:

insert image description here

  1. Check out the version number Projectin jdk.

jdkThe version number is 8, there is no problem here and no modification is required, as shown in the following figure:

insert image description here

  1. Viewing . Modules_Dependencies

Here , Module SDKthere is 8no problem and no modification is required, as shown in the following figure:

insert image description here

  1. Viewing . Modules_Source

Here language levelit is 12, as shown below:

insert image description here

Change this to 8, as shown in the following figure:

insert image description here

  1. At the same time, the modification pom.xmlis java.versionas 8shown in the following code
<properties>
    <java.version>8</java.version>
</properties>

insert image description here

  1. javaCompilerThose that are being modified Target bytecode versionmust correspond to your own jdkversion ( 我的jdk版本是8).

Click one 【File】-> 【Settings】-> 【Build, Execution, Deployment】-> 【Compiler】-> 【Java Compiler】by one to modify as shown in the figure below.

insert image description here

  1. Restart the project to start successfully, as shown in the following figure:

insert image description here

4. Supplementary Questions


If you have a problem like this:

Error:(3, 32) java: 无法访问org.springframework.boot.SpringApplication
  错误的类文件: /C:/Users/zxy/.m2/repository/org/springframework/boot/spring-boot/3.1.0/spring-boot-3.1.0.jar!/org/springframework/boot/SpringApplication.class
    类文件具有错误的版本 61.0, 应为 52.0
    请删除该文件或确保该文件位于正确的类路径子目录中。

insert image description here

You can refer to the blog post: Solve the inability to access org.springframework.boot.SpringApplication

Guess you like

Origin blog.csdn.net/lvoelife/article/details/130941594