![](/img/trans.png)
[英]Spring Boot @Mapper Bean creation issue : Application Failed to start. Error : Consider defining a bean of Type
[英]bean creation error when starting spring boot application
当我尝试运行我的 spring 引导应用程序时,出现此异常:
org.springframework.beans.factory.BeanCreationException:在 class 路径资源 [org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class] 中创建名为“configurationPropertiesBeans”的 bean 时出错:合并 bean 定义的后处理失败; 嵌套异常是 java.lang.IllegalStateException:无法自省 Class [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans] 来自 ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@3764951d]
我认为这是版本不兼容。 我在我的 pom.xml 中导入了 open feign,之后它就不起作用了,但我不知道如何解决这个问题。 我使用 open feign 2.2.5.RELEASE。 这是我的 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 引导版本设置为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'
...
}
我遇到了同样的问题,这是因为 Spring 云服务和 Spring 启动版本问题。 我通过使用https://start.spring.io/来生成我的项目来摆脱它。
当您 select 项目所需的所有依赖项时,您可以单击浏览按钮并检查pom.xml
文件。
当我在生成项目后尝试将Eureka-client
的依赖项添加到我的pom.xml
时,这个问题发生在我身上,因此使用 IntelliJ。
我得到了同样的错误。
Then I went to Spring.io again select dependencies that I use for my project and also dependency for Eureka-client
, clicked on Explore button and saw that I need to add this line of code under java version in pom.xml
<spring-cloud.version>2020.0.3</spring-cloud.version>
但也有这行:
<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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
所以我只是将它复制粘贴到我现有的pom.xml
并且它有效!
您需要将 spring 引导版本更改为已发布版本
从
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
至
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
所以这似乎是 SpringBoot vs Cloud Services 版本兼容性问题。 有没有一点可以看到Spring框架伞整体的版本兼容性矩阵? 谢谢!
Spring-Cloud - Hoxton.SR8 与 Spring-boot 2.4.0 不兼容
只需使用任何一种组合:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<spring-cloud.version>2020.0.3</spring-cloud.version>
或者
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<spring-cloud.version>Hoxton.SR8</spring-cloud.version>
您需要遵循 Spring Cloud 的发布序列并匹配 Spring-boot 启动器的版本。 发布火车可在 spring-cloud 网站https://spring.io/projects/spring-cloud
目前发布的火车是: spring-cloud的发布火车
只是更改为:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>3.1.1</version>
</dependency>
并将版本添加到
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.6.6</version>
</plugin>
</plugins>
</build>
为我工作得很好
这对我有用。 Go ti spring 初始化启动。spring.ZF98ED07A4D5F50F7DE1Z410 再次添加。 将 your.pom 与下载的 pom 进行比较。 我得到了我的问题。
<spring-cloud.version>2021.0.3-SNAPSHOT</spring-cloud.version>
我有不同版本的 spring 云,因此发生了冲突。
<repository>
<id>netflix-candidates</id>
<name>Netflix Candidates</name>
<url>https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
将此添加到存储库
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.