I want to achieve is that springboot gets the property values configured in the database to complete the automatic configuration. Just like using application.properties
Asked
Active
Viewed 482 times
1 Answers
0
It is possible to programatically override Spring properties at startup. This would be a good place to retrieve the properties from any database that you whish and set them.
Here is an example (copy/pasted from this answer) . You would have to add getting the configuration from the database
@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);
}
}

Thomas Vuillemin
- 134
- 8
-
How to perform database property query and override settings in the springboot startup method entry – jidianxiake Feb 19 '20 at 02:01
-
That is very dependant on what database you use, and how are the property saved in it. You would need to update your questions with those informations. But basically this should be about performing a simple query in the database – Thomas Vuillemin Feb 19 '20 at 07:15