Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/Configuration 和 出现 org.springframework.beans.factory.BeanCreationException 异常的原因及解决方法

将boot版本降低

问题原因

cloud 依赖版本跟 boot不一致

一般情况是 spring boot版本高于cloud版本

修改版本即可

例如 spring boot 版本是2.4.2

其他cloud依赖是 2.4以下 就会报错

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>2.4.2</version>

<relativePath/> <!-- lookup parent from repository -->

</parent>

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-starter-oauth2</artifactId>

<version>2.2.4.RELEASE</version>

</dependency>

————————————————

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.cxqy</groupId>
<artifactId>activity</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>activity</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR2</spring-cloud.version>
</properties>