启动Spring Boot应用程序时出现Bean创建错误
当我尝试运行我的Spring Boot应用程序时,我收到以下异常:
org.springframework.beans.factory.BeanCreationException:错误 创建在中定义的名为"ConfigurationPropertiesBeans"的Bean 类路径资源 [org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class]: 合并Bean定义的后处理失败;嵌套异常为 Java.lang.IlLegalStateException:未能自省类 [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans] 从ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@3764951d]
我认为这是版本不兼容。我在我的pom.xml中导入了Open Feign,之后它就不起作用了,但我不知道如何修复它。我用的是OPEN FIGN 2.2.5版本。 这里是我的pom.xml:
<?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.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>privas.microservice</groupId>
<artifactId>sellcar</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>sellcar</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>15</java.version>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
<spring-cloud.version>Hoxton.SR8</spring-cloud.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>2.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.4.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
解决方案
为了详细说明@M-deinum的评论,将Spring Boot版本设置为2.3.4.RELEASE
(而不是我的2.4.2
)解决了问题。在gradle
中,这意味着更改:
plugins {
id 'org.springframework.boot' version '2.4.2'
...
}
至
plugins {
id 'org.springframework.boot' version '2.3.4.RELEASE'
...
}
相关文章