Skip to content

Make it easier to map MessageSourceProperties onto a user-provided AbstractResourceBasedMessageSource #20791

@HermanBovens

Description

@HermanBovens

MessageSourceAutoConfiguration provides configuration of a ResourceBundleMessageSource in case a resource bundle is present and no other MessageSource bean is already configured.
However, in some cases a different subclass of AbstractResourceBasedMessageSource needs to be used in a Spring Boot application. For example, ReloadableResourceBundleMessageSource, or in our case a custom one with special handling of message arguments of a certain type.

While it is easy to define your own MessageSource bean which will override the auto-configuration, this has the drawback that automatic property configuration of the message source by using "spring.messages"-prefixed application properties is also lost.

MessageSourceAutoConfiguration currently calls the ResourceBundleMessageSource() constructor directly. All the methods that are then called on this message source are present on AbstractResourceBasedMessageSource. It would be convenient if we could configure a provider for AbstractResourceBasedMessageSource which would override an auto-configured one that instantiates ResourceBundleMessageSource directly, and which would then be further automatically configured using the "spring.messages"-prefixed application properties.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions