注:使用版本版本 spring cloud F SR2
优先级如下:
所以 本地kafka配置不能生效了。官方给出了解决方案如下:
2.4 Overriding the Values of Remote PropertiesThe property sources that are added to your application by the bootstrap context are often “remote” (from example, from Spring Cloud Config Server). By default, they cannot be overridden locally. If you want to let your applications override the remote properties with their own System properties or config files, the remote property source has to grant it permission by setting spring.cloud.config.allowOverride=true (it does not work to set this locally). Once that flag is set, two finer-grained settings control the location of the remote properties in relation to system properties and the application’s local configuration:spring.cloud.config.overrideNone=true: Override from any local property source.spring.cloud.config.overrideSystemProperties=false: Only system properties, command line arguments, and environment variables (but not the local config files) should override the remote settings.
也就是说
看起来很美好,配置下就可以了,但真正配置的时候要注意配置的位置,否则配置加载就会变的很混乱了。
一般配置有三个地方
本地配置
远程 properties
config server 下发配置
但是这样配置也会有一点点小坑,因为会默认本地有的配置就会优先采用,比如kafka的本地默认配置
如果我们想配置kafka序列化的模式比如在远程配置成key string 那就不会生效了,所以在使用的时候要注意类型即可。
总结下:
资料:
http://cloud.spring.io/spring-cloud-static/Finchley.SR2/single/spring-cloud.html
领取专属 10元无门槛券
私享最新 技术干货