1.Cloud对应Boot版本对照.
升级时对应boot版本也升级到2.1
更新文档:https://cloud.spring.io/spring-cloud-static/Greenwich.SR5/single/spring-cloud.html
2.升级后问题
Description:
The bean 'xxx.FeignClientSpecification' could not be registered. A bean with that name has already been defined and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
出现这个问题是因为FeginClient注册到Sping容器内时使用了相同的名称导致报错.
解决方法:
1.修改feignClient的名称, 显然这不现实.
2.使用@FeignClient(name = "xxx-service", contextId = "xxx", path = "/xxxx")
FeignClient注解新增了contextId用此id标识feign client不同上下文的名称, 这个最简单也是官方推荐的方式, 但是在某些时候由于用到了别的项目组的clientApi. 而别人不愿意改的话则只能使用第三种方式.
3.按照提示在配置文件中增加spring.main.allow-bean-definition-overriding=true配置.
注意:
使用spring-cloud-config时则需要增加到bootstrap.yml配置文件内
或者启动命令中增加-Dspring.main.allow-bean-definition-overriding=true也可.
因为此时程序还没读取到配置文件时已经报错了.
在2.0版本中没有报错是因为该属性默认为true(DefaultListableBeanFactory.allowBeanDefinitionOverriding)
在2.1版本中由SpringApplication.prepareContext方法中将该属性设置为了false
其中this.allowBeanDefinitionOverriding由于默认没有配置赋值所以默认为false.