【问题标题】:java: cannot access org.springframework.boot.SpringApplication bad class filejava: 无法访问 org.springframework.boot.SpringApplication 错误的类文件
【发布时间】:2022-11-28 13:56:24
【问题描述】:
java: cannot access org.springframework.boot.SpringApplication
  bad class file: /C:/Users/xyz/.m2/repository/org/springframework/boot/spring-boot/3.0.0-SNAPSHOT/spring-boot-3.0.0-20220910.145857-773.jar!/org/springframework/boot/SpringApplication.class
    class file has wrong version 61.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

【问题讨论】:

    标签: maven intellij-idea boot sprint


    【解决方案1】:

    如果您的计算机上安装了 java 8,并且如果您访问 spring initializer 网站并通过选择 Spring boot 3.0.0 (SNAPSHOT) 并打包为 Jar 和版本为 8 来创建应用程序,则生成的 zip 文件的版本将为 11在 pom 上,即使您选择的版本为 8。这意味着,您的本地计算机的 java 版本为 8,而生成的 zip 文件在 pom 上的版本为 11。

    【讨论】:

      【解决方案2】:

      class文件版本61.0错误,应该是52.0

      参考List of Java class file format major version numbers?。和类似的问题Class file has wrong version 52.0, should be 50.0 它表明您使用的是 java 8,但类文件是为 java 17 编译的。
      原因是 Spring Boot 3 需要 java 17,如 Preparing for Spring Boot 3.0 中所述。

      【讨论】:

        【解决方案3】:

        从 3.0.0 到 2.7.3 ,我改变了。然后一切顺利。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2022-12-01
          • 2020-12-07
          • 2022-06-17
          • 1970-01-01
          • 1970-01-01
          • 2018-07-20
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多