Springboot如何使用数据库而不是application.properties



我想要实现的是springboot获取数据库中配置的属性值,以完成自动配置。就像使用application.properties 一样

启动时可以用程序重写Spring属性。这将是一个很好的地方,可以从您whish和设置的任何数据库中检索属性。

下面是一个例子(从这个答案中复制/粘贴(。您必须添加从数据库获取配置

@SpringBootApplication
public class Demo40Application{
public static void main(String[] args){
SpringApplication application = new SpringApplication(Demo40Application.class);
Properties properties = new Properties();
properties.put("server.port", 9999);
application.setDefaultProperties(properties);
application.run(args);
}
}

最新更新