springboot项目在编译时报错:
/Users/Apple/Developer/art/caicai/cai-api/dubbo-samples/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/src/main/java/org/apache/dubbo/springboot/demo/provider/ProviderApplication.java:22:32
java: 无法访问org.springframework.boot.SpringApplication
错误的类文件: /Users/Apple/.m2/repository/org/springframework/boot/spring-boot/3.2.3/spring-boot-3.2.3.jar!/org/springframework/boot/SpringApplication.class
类文件具有错误的版本 61.0, 应为 52.0
请删除该文件或确保该文件位于正确的类路径子目录中。
经过百度了发现是springboot版本过高,项目的pom文件中我的springboot版本为3.0,而java的版本为1.8,导致不匹配报错。
原先的pom文件:
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<dubbo.version>3.3.1</dubbo.version>
<spring-boot.version>3.2.3</spring-boot.version>
</properties>
解决办法:降低springboot的版本。
修改后的pom文件:
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<dubbo.version>3.3.1</dubbo.version>
<spring-boot.version>2.6.13</spring-boot.version>
</properties>
编译结果:
[INFO] Dubbo Samples Spring Boot .......................... SUCCESS [ 0.218 s]
[INFO] dubbo-samples-spring-boot-interface ................ SUCCESS [ 0.006 s]
[INFO] dubbo-samples-spring-boot-provider ................. SUCCESS [ 1.816 s]
[INFO] dubbo-samples-spring-boot-consumer ................. SUCCESS [ 0.046 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.243 s
[INFO] Finished at: 2024-11-09T14:19:18+08:00
[INFO] ------------------------------------------------------------------------
进程已结束,退出代码为 0
参考链接:https://blog.csdn.net/simonchi/article/details/126625381
标签:INFO,dubbo,SpringBoot,spring,boot,61.0,报错,samples,springboot From: https://blog.csdn.net/Poboll/article/details/143644651