博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring Cloud Greenwich 新特性和F升级分享
阅读量:7050 次
发布时间:2019-06-28

本文共 2182 字,大约阅读时间需要 7 分钟。

2019.01.23 期待已久的Spring Cloud Greenwich 发布了release版本,作为我们团队也第一时间把RC版本替换为release,以下为总结,希望对你使用Spring Cloud Greenwich 有所帮助

Greenwich 只支持 Spring Boot 2.1.x 分支。如果使用 2.0.x 请使用Finchley版本,

pom坐标

主要是适配JAVA11

org.springframework.boot
spring-boot-dependencies
2.1.2.RELEASE
pom
import
org.springframework.cloud
spring-cloud-dependencies
Greenwich.RELEASE
pom
import

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

image

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

这里提供了一个例子:

整合的时候有个坑可以参考这个issue:

新增重写响应头过滤器

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

Feign 的新特性和坑

@SpringQueryMap 对Get请求进行了增强

  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=trueProcess 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. ^_^

转载地址:http://ajcol.baihongyu.com/

你可能感兴趣的文章
简述原型链是什么,有什么用处?若想访问一个对象的原型,应该使用什么方法?...
查看>>
[LeetCode] 675. Cut Off Trees for Golf Event
查看>>
SQLServer之锁简介
查看>>
从点餐小程序说起,谈谈如何从0到1设计一款toB类产品
查看>>
CSS相对定位和绝对定位
查看>>
断开TCP连接
查看>>
我的前端集成测试(一)- 认识node的assert模块
查看>>
【跃迁之路】【465天】程序员高效学习方法论探索系列(实验阶段222-2018.05.16)...
查看>>
spring4.x 集成quartz2.x 集群化配置项目实例
查看>>
Spring Boot 参考指南(开发者工具)
查看>>
慢雾科技和 SegmentFault 达成战略合作
查看>>
TypeScript 2.9
查看>>
Linux 程序包的管理
查看>>
JavaScript 异步、栈、事件循环、任务队列
查看>>
图解 React Virtual DOM
查看>>
Day08 - HTML5 Canvas 实现彩虹画笔绘画板指南
查看>>
Netty防止内存泄漏措施
查看>>
Spring Boot [组件学习-Spring Data JPA]
查看>>
百度云磁盘CDS、对象存储BOS技术深度解析
查看>>
独家!阿里开源自用OpenJDK版本,Java社区迎来中国力量
查看>>