Spring Cloud Greenwich 新特性和F升级分享

Stella981
• 阅读 525

2019.01.23 期待已久的Spring Cloud Greenwich 发布了release版本,作为我们团队也第一时间把RC版本替换为release,以下为总结,希望对你使用Spring Cloud Greenwich 有所帮助 Greenwich 只支持 Spring Boot 2.1.x 分支。如果使用 2.0.x 请使用Finchley版本,

pom坐标

主要是适配JAVA11

<!--支持Spring Boot 2.1.X-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-dependencies</artifactId>
    <version>2.1.2.RELEASE</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>
<!--Greenwich.RELEASE-->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-dependencies</artifactId>
    <version>Greenwich.RELEASE</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>

升级netflix版本,DiscoveryClient支持获取InstanceId

Spring Cloud Greenwich 新特性和F升级分享

Spring Cloud Config 提供了新的存储介质

除了Git、File、JDBC,新版本提供 在Cloud Foundry的CredHub存储功能

spring:
  profiles:
    active: credhub
  cloud:
    config:
      server:
        credhub:
          url: https://credhub:8844

Spring Cloud Gateway

支持整合OAuth2

这里提供了一个例子: Spring Cloud Gateway and Spring Security OAuth2

整合的时候有个坑可以参考这个issue:ReactiveManagementWebSecurityAutoConfiguration Prevent's oauth2Login from being defaulted

新增重写响应头过滤器

spring:
  cloud:
    gateway:
      routes:
      - id: rewriteresponseheader_route
        uri: http://example.org
        filters:
        - RewriteResponseHeader=X-Response-Foo, , password=[^&]+, password=***

Feign 的新特性和坑

@SpringQueryMap 对Get请求进行了增强

Spring Cloud Greenwich 新特性和F升级分享

  1. 终于解决这个问题了
  2. 不用直接使用OpenFeign新增的@QueryMap,由于缺少value属性 QueryMap注释与Spring不兼容...

异常解决

对Spring Cloud Finchley 进行直接升级时候发现feign启动报错了

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'pigx-upms-biz.FeignClientSpecification', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true


Process finished with exit code 1
  1. 第一种粗暴的解决方法,异常日志中说明了,在 bootstrap.yml中配置

    spring.main.allow-bean-definition-overriding=true

这是Spring Boot 2.1 后新增的属性运行bean 覆盖,不要配置到配置中心里面,不然无效

  1. 第二种,就是把通过同一个服务调用的代码,移动到同一个@FeignClient中

  2. contextId ,这个是@FeignClient 新增的一个属性

    This will be used as the bean name instead of name if present, but will not be used as a service id.

就可以用这个属性区分@FeigenClient 标志的同一个service 的接口

总结

  1. Spring Cloud F -- > G 变化很小,微乎其微主要是JAVA11的兼容
  2. 很遗憾没有看到 Spring Cloud Alibaba 加油。
  3. Spring Cloud LoadBalancer 还是老样子。目前来看暂时无法替代 ribbon
  4. 欢迎加我Q2270033969,讨论Spring Cloud ^_^
点赞
收藏
评论区
推荐文章
Easter79 Easter79
2年前
Vue 3.0 已经正式发布!你想知道的这里都有!
Vue团队于2020年9月18日晚11点半发布了Vue3.0版本,我们连夜对Release进行了翻译。由于时间仓促,文中如有翻译不当的地方还望提出。如有侵权,请联系删帖。以下为译文正文。今天,我们非常自豪地宣布Vue.js3.0"OnePiece"发布。本次主版本更新包含性能的改进,更小的bundle体积,对
Stella981 Stella981
2年前
Nexus 3 使用 Maven 坐标搜索时,Version 字段搜索不到 SNAPSHOT 版本的组件
近期将NexusRepositoryMannager2升级到 NexusRepositoryMannager3使用Maven坐标搜索,Version字段可以搜索到release版本的组件,却搜索不到SNAPSHOT版本的组件而用baseVersion可以搜索到release版本的组件,也可以搜索到SNAPSH
Stella981 Stella981
2年前
Spring Cloud Gateway跨域配置
版本:Greenwich.SR2 1.官网配置https://cloud.spring.io/springcloudstatic/springcloudgateway/2.2.1.RELEASE/reference/html/corsconfiguration(https://www.oschina.net/action/GoTo
Stella981 Stella981
2年前
OAuth2 升级Spring Cloud Finchley.RELEASE踩坑分享
背景6.19号,spring团队发布了期待已久的SpringCloudFinchley.RELEASE版本。重要变化:基于SpringBoot2.0.X不兼容SpringBoot1.5.X期间踩过几个坑,分享出来给大伙,主要是关于SpringCloudoAuth部分目标基于
Stella981 Stella981
2年前
Spring Cloud Greenwich.SR4发布
SpringCloudGreenwichReleaseTrain的ServiceRelease4(SR4)现已发布。该版本可以在MaveCentral中找到。您可以查看Greenwich发行说明以获取更多信息。SpringCloudGreenwich.SR4底层依赖升级至SpringBoot2.1.10.RELEASE
Stella981 Stella981
2年前
Nepxion Discovery 5.4.0 旗舰版发布
!(https://oscimg.oschina.net/oscnet/be52601eb57e4b05b570ea45cb22fad2.png)发布日志版本更新:升级SpringCloud到Greenwich.SR3,确定对SpringCloudHoxton版的支持计划升级Spri
Stella981 Stella981
2年前
GitHub Actions
使用GitHubActions发布版本时,获取触发的tag作为发布的版本号.方式一通过step获取tag,在需要使用的地方使用steps.get_version.outputs.VERSION,其中get_version是step的id.name:Release
Stella981 Stella981
2年前
Redis 6.0 新特性概览
前言Redis6RC2于今年3月5号Release,预计今年4.30月份发布GA版本,官方网站提供unstable版本的供大家测试,本文基于官方文档介绍Redis6的重要的新特性。作者对新特性的介绍http://antirez.com/news/131ACL在Redis5版本之前,Redis安全规则只有密码控制
Stella981 Stella981
2年前
Spring Boot Admin 2 值得了解的新变化
6.19号,spring团队发布了期待已久的SpringCloudFinchley.RELEASE版本。期间SpringBootAdmin也发布了2.0.1兼容它,我在升级pig到Finchley.RELEASE的同时发现很多有意思的变化整理发出来关于pig:基于SpringCloud、oAut
京东云开发者 京东云开发者
7个月前
Java21上手体验-分代ZGC和虚拟线程 | 京东云技术团队
一、导语几天前Oracle刚刚发布了Java21,由于这是最新的LTS版本,引起了大家的关注。我也第一时间在个人项目中进行了升级体验。一探究竟,和大家分享。二、Java21更新内容介绍官方release公告:开源中国介绍:新特性一览:JEP431:序列集合