英文:
Class file has wrong version 61.0, should be 52.0
问题
I want to create a Spring Boot project on Intellij Idea and i choose Java 8 and Java 1.8 sdk but when i open the pom.xml i saw my java version is 17 !? how can it possible ?
当我打开 pom.xml 时,我选择了 Java 8 和 Java 1.8 SDK 创建 Spring Boot 项目,但我看到我的 Java 版本是 17!?这怎么可能?
When i run my project i see this message below and how can my jars version 6.0.7 ?;
当我运行我的项目时,我看到下面的消息,我的 jar 版本是 6.0.7?;
java: cannot access org.springframework.http.HttpStatus
bad class file: /C:/Users/eegee/.m2/repository/org/springframework/spring-web/6.0.7/spring-web-6.0.7.jar!/org/springframework/http/HttpStatus.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.
英文:
I want to create a Spring Boot project on Intellij Idea and i choose Java 8 and Java 1.8 sdk but when i open the pom.xml i saw my java version is 17 !? how can it possible ?
When i run my project i see this message below and how can my jars version 6.0.7 ?;
java: cannot access org.springframework.http.HttpStatus
bad class file: /C:/Users/eegee/.m2/repository/org/springframework/spring-web/6.0.7/spring-web-6.0.7.jar!/org/springframework/http/HttpStatus.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.
答案1
得分: 4
- 检查Spring Boot的版本。例如,Spring Boot 3.X基线需要Java 17。
- 在父
pom.xml
中明确指定所需的Java版本(并将其应用于所有模块):<properties> <java.version>1.8</java.version> </properties>
- 如果使用
maven-compiler-plugin
,还需要检查其属性中的版本:<properties> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.source>1.8</maven.compiler.source> </properties>
或者,可以在插件配置中明确指定:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin>
英文:
There are three things you can check or do:
- Check the version of Spring Boot. For example, Spring Boot 3.X baseline requires Java 17.
- Specify explicitly the required Java version in the parent
pom.xml
(and apply it to all modules as well).<properties> <java.version>1.8</java.version> </properties>
- In case you use
maven-compiler-plugin
, you also want to check the version in its properties:<properties> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.source>1.8</maven.compiler.source> </properties>
Alternatively, specify it inside the plugin configuration itself:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin>
答案2
得分: 0
如果您正在使用JDK >17和最新的库,例如Spring 6,请使用版本5.1.0(发布说明)。如果您使用较旧的JDK或库,请使用版本4.44.0(文档)。
查看它
对我来说,您应该使用4.44.0
当我解决了问题后,它对我起作用了
英文:
If you are using JDK >17 and up-to-date libraries like Spring 6, use version 5.1.0 (Release Notes). If you are on older JDK or library, use version 4.44.0 (documentation).
Look on it
It seems to me that ypu should use 4.44.0
It worked for me when I corrected with problem
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论