Springboot startup error [main] osboot.SpringApplication: Application run failed (It may be a version problem)

Foreword: I am a novice. Recently, I encountered a small problem when I was learning JAVA by myself. After solving it on the Internet to no avail, I found the reason myself. I will share it with you here.

Development environment: Win10; IntelliJ IDEA 2021.3.2

Version information: Java\jdk-17.0.2; apache-maven-3.8.4-bin; springboot2.3.4

Programming purpose: I didn't know anything about JAVA before. Recently, when I was learning JAVA by myself, I wanted to use JAVA, Springboot and maven to build a most basic helloworld program.

Error message:

  "osboot.SpringApplication : Application run failed" is displayed after ERROR. But this is just a phenomenon, drag down to see the "caused by" section, there are a few long lines of information, don't be bothered, drag it back to see, or more quickly select two lines and copy them out, so that you don't have to drag a little bit . You will see the following message: "Unsupported class file major version 61"

   This prompt message is actually very obvious. Just to tell you that the version is not supported. After some research, I found that the root cause was that my JDK version was too high to adapt to springboot2.3.4. So I uninstalled the original jdk-17.0.2 version and downloaded a historical version of jdk-8u291-windows-x64, and then don't forget to configure the PATH environment variable. Then enter IDEA again to run.

  There is a small pit here, that is, if you use JDK17 before to create and run a project, after you change the version, your original project is still JDK17, which does not support your newly installed version, so you need to change the compiler settings, And create a new project again (there are still some configurations that need to be changed, this will not be detailed, just search other posts online for more details), when you get to the project code, if you copy the original project code directly, you will find Still can't run, first you go to pox.xml to find the following code:

<properties>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
</properties>

The 17 in the middle means that the compiler used in your current project is version 17, so you should change the 17 in the above code to 8 (or other versions you newly installed).

  Run the program again, if there is no accident, you can run it.

  pps: When I was looking for a solution, I tried the method of "exclude it from injecting 
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})" in @SpringBootApplication, but at least in my environment it doesn't matter. use. Therefore, when you encounter a problem, don't blindly try it. You should read the error message and maybe you can find the answer yourself.

that's all.

Guess you like

Origin blog.csdn.net/weixin_45645926/article/details/122894572