启动服务报错
java.lang.NoClassDefFoundError: org/springframework/boot/logging/DeferredLogFactory
原因:创建项目后更改了springboot 版本,从 2.7.4 改为 2.2.4.RELEASE,导致 boot 与 cloud 版本不兼容,查看官网改成对应版本即可
https://start.spring.io/actuator/info
"Hoxton.SR7": "Spring Boot >=2.2.0.M4 and <2.3.4.BUILD-SNAPSHOT"
spring-cloud":{
"Hoxton.SR12":"Spring Boot >=2.2.0.RELEASE and <2.4.0.M1"
,
“2020.0.6”:“Spring Boot >=2.4.0.M1 and <2.6.0-M1”,
“2021.0.0-M1”:“Spring Boot >=2.6.0-M1 and <2.6.0-M3”,
“2021.0.0-M3”:“Spring Boot >=2.6.0-M3 and <2.6.0-RC1”,
“2021.0.0-RC1”:“Spring Boot >=2.6.0-RC1 and <2.6.1”,
“2021.0.4”:“Spring Boot >=2.6.1 and ❤️.0.0-M1”,
“2022.0.0-M1”:“Spring Boot >=3.0.0-M1 and ❤️.0.0-M2”,
“2022.0.0-M2”:“Spring Boot >=3.0.0-M2 and ❤️.0.0-M3”,
“2022.0.0-M3”:“Spring Boot >=3.0.0-M3 and ❤️.0.0-M4”,
“2022.0.0-M4”:“Spring Boot >=3.0.0-M4 and ❤️.1.0-M1”}
解决方法:将 cloud 版本改为 boot 兼容版本
如:Hoxton.SR12 、 Hoxton.SR7
这里选择改为 Hoxton.SR12
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR12</spring-cloud.version>
</properties>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.4.RELEASE</version>
</dependency>
<!-- cloud 版本改为 Hoxton.SR12 即可 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>