Adding environment repository in Spring Config Server

两盒软妹~` 提交于 2019-12-04 19:36:07

you certainly can. See spring cloud consul config as an example. The guts is a PropertySource

public class MyPropertySource extends EnumerablePropertySource<MyClient> {
  @Override
  public Object getProperty(String name) {
    return /* your impl */;
  }

  @Override
  public String[] getPropertyNames() {
    return /* your impl here */;
  }
}

You also need a PropertySourceLocator, a bootstrap configuration and a META-INF/spring.factories that points to the bootstrap config`.

Felix Oldenburg

As spencergibb stated in another thread, a PropertySource only provides configuration for the config server itself and is not accessible for the spring boot config clients.

What you actually need is an implementation of the EnvironmentRepository interface. I provided an example for a simple CustomEnvironmentRepository in Spring Boot Config custom environment repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!