Skip to content

Add a MapperBuilder#findAndAddModules(ClassLoader) variant #5112

@sdeleuze

Description

@sdeleuze

Is your feature request related to a problem? Please describe.

With Jackson 3, Spring Framework 7 is switching to using the Jackson support for service loader to enable Jackson modules by default. It would be very useful for us to have a MapperBuilder#findAndAddModules(ClassLoader) along to the current MapperBuilder#findAndAddModules() shortcut to promote this as a first class use case within the Spring portfolio. Any chance you could add it?

Describe the solution you'd like

We would like to be be able to write:

public MappingJacksonHttpMessageConverter() {
    this(JsonMapper.builder()
            .findAndAddModules(MappingJacksonHttpMessageConverter.class.getClassLoader())
            .build());
}

Instead of:

public MappingJacksonHttpMessageConverter() {
    this(JsonMapper.builder()
            .addModules(MapperBuilder.findModules(MappingJacksonHttpMessageConverter.class.getClassLoader()))
            .build());
}

Usage example

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.0Issue planned for initial 3.0 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions