I have a situation where I need a property value (application.name) before the application context is loaded - spring boot, before SpringApplication.run is called, and during context loading.
In my ApplicationMain class which calls SpringApplication.run, I have a constant public static final NAME = "MyApplicationName".
My issue is that we have some libraries that are injecting the value via @Value("${application.name}").
Is there a way set the application.name property in the context from this constant value?
I was thinking I could do a post-construct and then set it in the environment - similar to the solution described here, but that doesn't guarantee that it will be available for all injections by @Value.
I was hoping there was a similar mechanism to @Bean on a method which could set the value for the property, but I don't see one anywhere.