Skip to content

Allow other strategies than META-INF/spring.factories for configuring Spring Boot infrastructure #15704

Closed
@sdeleuze

Description

@sdeleuze

In order to make Spring Boot a better citizen with GraalVM native image generation, in Spring Fu I would like to replace META-INF/spring.factories mechanism by a custom way to provide ApplicationContextInitializer, ApplicationListener, PropertySourceLoader, EnvironmentPostProcessor and SpringApplicationRunListener instances. But SpringFactoriesLoader usage is currently impossible to disable. I think @dsyer have also a similar need.

In my use case, the functional configuration provided by the user will be used to provide the implementations. This will make the configuration more modular and will make Boot infrastructure a better citizen with GraalVM native image which requires currently a huge mount of reflection configuration because these classes are defined in a property file invisible to GraalVM static code analysis.

In term of software design, I tend to think providing constructors or setters where one can provide a list of instances instead of using internally META-INF/spring.factories, and making SpringFactoriesLoader only the default way to get implementations for those classes would improve testability, extensibility, and would make dependencies more explicit.

I am also wondering if such improvement could be used to replace SpringFactoriesLoader (which was initially designed to customize Spring Framework internals for Scala support if I am not mistaken) by another mechanism like Java ServiceLoader which is natively compatible with GraalVM native image.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions