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

Activity

added
to-evaluateIssue that has been received but not yet evaluated
on Apr 25, 2025
cowtowncoder

cowtowncoder commented on Apr 25, 2025

@cowtowncoder
Member

Since there are both

    public B findAndAddModules() {
        return addModules(findModules());
    }

    public static List<JacksonModule> findModules(ClassLoader classLoader) { ... }

that seems very much doable, will add.

added a commit that references this issue on Apr 25, 2025
6d18de7
added
3.0Issue planned for initial 3.0 release
and removed
to-evaluateIssue that has been received but not yet evaluated
on Apr 25, 2025
added a commit that references this issue on Apr 25, 2025
1450671
cowtowncoder

cowtowncoder commented on Apr 25, 2025

@cowtowncoder
Member

Fixed via #5114.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @cowtowncoder@sdeleuze

        Issue actions

          Add a `MapperBuilder#findAndAddModules(ClassLoader)` variant · Issue #5112 · FasterXML/jackson-databind