If a library provides a listener for ApplicationEnvironmentPreparedEvent (for instance) in spring.factories it can modify the SpringApplication (add sources, change the application context class, etc.) but there is no way to know if the user has already done that before calling run(). It would be useful in general to be able to do that, so that the library can respect the user's wishes and still provide defaults. Specifically I am interested in the application context factory, but maybe also other things.

Various ideas popped up when we discussed informally:

  1. public getters for everything in SpringApplication is an option, but not likely to be desirable.
  2. a new ApplicationEvent that can be fired from the constructor.
  3. extracting "default provider" concern to a new component (so the library can override that instead of calling setters directly).

Comment From: philwebb

I feel like option 3) is the least invasive. We could leave fields null in SpringApplication and then delegate to some SpringApplicationDefaults instance that could provide the default values.

Comment From: snicoll

We've discussed this one and there hasn't been interest from the community in the last 4 years so we're going to close it.