|
|
@ -38,8 +38,7 @@ import com.fasterxml.jackson.databind.cfg.ConstructorDetector;
|
|
|
|
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
|
|
|
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.BeanFactoryUtils;
|
|
|
|
import org.springframework.beans.factory.ObjectProvider;
|
|
|
|
import org.springframework.beans.factory.ListableBeanFactory;
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
@ -171,21 +170,21 @@ public class JacksonAutoConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
|
StandardJackson2ObjectMapperBuilderCustomizer standardJacksonObjectMapperBuilderCustomizer(
|
|
|
|
StandardJackson2ObjectMapperBuilderCustomizer standardJacksonObjectMapperBuilderCustomizer(
|
|
|
|
ApplicationContext applicationContext, JacksonProperties jacksonProperties) {
|
|
|
|
JacksonProperties jacksonProperties, ObjectProvider<Module> modules) {
|
|
|
|
return new StandardJackson2ObjectMapperBuilderCustomizer(applicationContext, jacksonProperties);
|
|
|
|
return new StandardJackson2ObjectMapperBuilderCustomizer(jacksonProperties, modules.stream().toList());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static final class StandardJackson2ObjectMapperBuilderCustomizer
|
|
|
|
static final class StandardJackson2ObjectMapperBuilderCustomizer
|
|
|
|
implements Jackson2ObjectMapperBuilderCustomizer, Ordered {
|
|
|
|
implements Jackson2ObjectMapperBuilderCustomizer, Ordered {
|
|
|
|
|
|
|
|
|
|
|
|
private final ApplicationContext applicationContext;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final JacksonProperties jacksonProperties;
|
|
|
|
private final JacksonProperties jacksonProperties;
|
|
|
|
|
|
|
|
|
|
|
|
StandardJackson2ObjectMapperBuilderCustomizer(ApplicationContext applicationContext,
|
|
|
|
private final Collection<Module> modules;
|
|
|
|
JacksonProperties jacksonProperties) {
|
|
|
|
|
|
|
|
this.applicationContext = applicationContext;
|
|
|
|
StandardJackson2ObjectMapperBuilderCustomizer(JacksonProperties jacksonProperties,
|
|
|
|
|
|
|
|
Collection<Module> modules) {
|
|
|
|
this.jacksonProperties = jacksonProperties;
|
|
|
|
this.jacksonProperties = jacksonProperties;
|
|
|
|
|
|
|
|
this.modules = modules;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -305,8 +304,7 @@ public class JacksonAutoConfiguration {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void configureModules(Jackson2ObjectMapperBuilder builder) {
|
|
|
|
private void configureModules(Jackson2ObjectMapperBuilder builder) {
|
|
|
|
Collection<Module> moduleBeans = getBeans(this.applicationContext, Module.class);
|
|
|
|
builder.modulesToInstall(this.modules.toArray(new Module[0]));
|
|
|
|
builder.modulesToInstall(moduleBeans.toArray(new Module[0]));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void configureLocale(Jackson2ObjectMapperBuilder builder) {
|
|
|
|
private void configureLocale(Jackson2ObjectMapperBuilder builder) {
|
|
|
@ -340,10 +338,6 @@ public class JacksonAutoConfiguration {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static <T> Collection<T> getBeans(ListableBeanFactory beanFactory, Class<T> type) {
|
|
|
|
|
|
|
|
return BeanFactoryUtils.beansOfTypeIncludingAncestors(beanFactory, type).values();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|