部署SpringCloud,运行启动类报错org.springframework.beans.BeanInstantiationException: Failed to ..解决方案

部署SpringCloud项目,运行eureka启动类报错:org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans]: Factory method ‘configurationPropertiesBeans’ threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
网上找了好久也没有找到解决方案,经人指导,才发现问题出在SpringBoot和SpringCloud版本不对应。

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.3</version>
        <relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Hoxton.SR8</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

可以看出SpringBoot的版本是2.4.3,SpringBoot对应的版本是Hoxton.SR8,查看spring.io官网,发现版本对应如下:
在这里插入图片描述
可以看出Hoxton对应SpringBoot的2.2.x、2.3.x版本,将SpringCloud的版本改为2.2.6.RELEASE,问题就解决了!


版权声明:本文为Matthew_99原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。