第一次使用Spring Cloud就出错

使用Spring Cloud遇到的问题以及解决方案

出错

Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2020-12-21 21:41:42.849 ERROR 3236 — [ main] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘configurationPropertiesBeans’ defined in class path resource [org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans]: Factory method ‘configurationPropertiesBeans’ threw exception;

先来看看我的spring-boot版本和spring-cloud版本

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.4.1</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <java.version>11</java.version>
    <spring-cloud.version>Greenwich.SR1</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>

然后去官网查了一下是Spring Cloud的版本和Spring Boot的版本对不上。

贴上Spring Cloud的官网地址:Spring Cloud

目前Spring Cloud发布的正式版本最高是Hoxton.SR9,仅支持到Spring Boot的2.3.5.RELEASE版本
在这里插入图片描述

点进去Hoxton.SR9的页面我们可以看到Spring-Cloud最新的稳定版本Hoxton.SR9支持Spring Boot的版本仅仅到: 2.3.5.RELEASE
在这里插入图片描述

如果要能支持Spring Boot 2.4.1的话,需要使用2020.0.0-SNAPSHOT版本的Spring Cloud
在这里插入图片描述

Spring Boot版本和Spring Cloud版本的对照
在这里插入图片描述
最后我将Spring Boot的版本换为2.3.5.RELEASE,Spring Cloud的版本换为:Hoxton.SR9,然后就可以成功运行了

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.3.5.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <java.version>11</java.version>
    <spring-cloud.version>Hoxton.SR9</spring-cloud.version>
</properties>

在这里插入图片描述

Spring Cloud的命名风格

初次导入Spring Cloud的时候就感觉它的版本号有些奇怪
在这里插入图片描述
后来才知道这些版本名称的命名方式采用了伦敦地铁站的名称,同时根据字母表的顺序来对应版本时间顺序,比如:最早的Release版本:Angel,其次是,Brixton,Camden、Dalston、Edgware,Finchley,Greenwich,然后到现在的:Hoxton。IIford这个版本应该是快要发布但是还没有发布的吧。不得不说开发人员命名真随意呀。

Spring Cloud功能总览

一直在说Spring Cloud,那Spring Cloud究竟能提供什么功能呢,下面做了一个简单的归纳。

思维导图获取点此链接

在这里插入图片描述

软件的版本

借此机会说一下软件的版本问题

我们在下载软件会遇到诸如:
release,stable,alpha,beta,pre,current,eval,rc,snapshot等版本,现在我说明以下版本的意思:
参考自:软件版本中的release,stable,alpha,beta,pre,snapshot

  1. snapshot(快照),也即开发版,我们创建maven项目时,编辑器会自动给我们填入 1.0-SNAPSHOT版本,也就是1.0开发版,这个版本不能使用,因为该版本处于开发的过程,所以运行时会不时地更新,导致功能变化,正式环境中不得使用snapshot版本的库;

  2. alpha,内部测试版,来源于字母α,是比较早的版本,主要是给开发人员和测试人员测试和找BUG用的,不建议使用;

  3. beta,公开测试版,来源于字母β,这是比alpha进一步的版本,面向公众测试,但是不建议使用

  4. pre,这个和alpha版本类似,有时还会细分为M1,M2版本,不建议使用;

  5. RC(Release Candidate)候选版本。系统平台上就是发行候选版本;

  6. GA(General Availability)正式发布的版本,在国外都是用GA来说明release版本的;

  7. release,发行版,这是release的中文意思,也就是官方推荐使用的版本;

  8. stable,稳定版,这个版本相比于测试版更加稳定,去除了测试版许多的bug,完善了一些功能,建议使用;

  9. current,最新版,但是不一定是稳定版本,需要看一下是否还有release或者stable等版本;

  10. eval,评估版。可能会有一个月或者固定时间的使用期限;

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐