I'm probably missing something obvious, but I am trying to figure out how to set/override properties from a Spring Boot SpringApplication programatically when running the app.
By default, I know I can pass command line arguments to the boot application, but I want to embed the spring boot application in another java app, and executed from within the parent app. I've included it as a dependency to my project.
In my Spring Boot application I have the following:
static public main(String [] args){
SpringApplication app = new SpringApplication(Sync.class);
app.setWebEnvironment(false);
app.setShowBanner(false);
app.run(args);
}
This allows me to set command line arguments, such as --userName=Eric
etc.
Although I realize I can technically do the same programmatically and add --userName=Eric
to my args[] array in code, I figured there must be another cleaner/neater way to pass an argument/property to my app
. But I cannot seem to find any other method in SpringApplication
that allows me to set that type of value.
I'm looking for something that would allow me to do something like the following:
app.setProperty("username", "Eric");
Am I missing something obvious?