SpringCloud--Alibaba入门(OpenFeign、GateWay、Seata)

程序员 2024-9-15 23:02:22 93 0 来自 中国
接着SpringCloud--Alibaba入门(Nacos+Sentinel),前次利用了SpringCloudAlibaba中的Nacos和Sentinel,此中Nacos作为微服务的焦点,不仅仅拥有服务注册中央、服务发现,另有设置中央的功能,而且自带Ribbon;Sentinel为保障团体微服务架构的高可用,拥有流控、熔断等功能,剩下另有OpenFeign、GateWay、Seata。
一、OpenFeign

Netflix也是利用的OpenFeign,以是用法是一致的
创建项目,作为服务调用者:
1.png 1.根本利用

1.1 依赖

除了nacos服务发现依赖外,还必要OpenFeign依赖,OpenFeign是SpringCloud中的组件,必要注意和SpringBoot的版本关系:
Spring Cloud Alibaba VersionSpring Cloud VersionSpring Boot Version2021.0.1.0Spring Cloud 2021.0.12.6.32.2.7.RELEASESpring Cloud Hoxton.SR122.3.12.RELEASE2021.1Spring Cloud 2020.0.12.4.22.2.6.RELEASESpring Cloud Hoxton.SR92.3.2.RELEASE2.1.4.RELEASESpring Cloud Greenwich.SR62.1.13.RELEASE2.2.1.RELEASESpring Cloud Hoxton.SR32.2.5.RELEASE2.2.0.RELEASESpring Cloud Hoxton.RELEASE2.2.X.RELEASE2.1.2.RELEASESpring Cloud Greenwich2.1.X.RELEASE2.0.4.RELEASE(制止维护,建议升级)Spring Cloud Finchley2.0.X.RELEASE1.5.1.RELEASE(制止维护,建议升级)Spring Cloud Edgware1.5.X.RELEASE父项目SpringBoot版本为2.3.12.RELEASE,以是导入SpringCloud的Hoxton.SR12依赖:
    <parent>        <artifactId>spring-boot-starter-parent</artifactId>        <groupId>org.springframework.boot</groupId>        <version>2.3.12.RELEASE</version>        <relativePath/>    </parent>    <properties>        ...        <spring-cloud.version>Hoxton.SR12</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>子项目导入OpenFeign依赖:
您需要登录后才可以回帖 登录 | 立即注册

Powered by CangBaoKu v1.0 小黑屋藏宝库It社区( 冀ICP备14008649号 )

GMT+8, 2024-10-19 00:26, Processed in 0.169445 second(s), 35 queries.© 2003-2025 cbk Team.

快速回复 返回顶部 返回列表