Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/Configuration 和 出現 org.springframework.beans.factory.BeanCreationException 異常的原因及解決方法
阿新 • • 發佈:2021-08-17
將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>