Extract GSON/Jackson config to inner classes

Update JsonTestersAutoConfiguration so that GSON and Jackson specific
configuration are inner classes. This should prevent ClassNotFound
exception when the libraries are not on the classpath.

Fixes gh-6502
pull/6542/head
Phillip Webb 8 years ago
parent 80a1897ccb
commit f38bd7af37

@ -66,27 +66,36 @@ public class JsonTestersAutoConfiguration {
null);
}
@ConditionalOnClass(ObjectMapper.class)
private static class JacksonJsonTestersConfiguration {
@Bean
@Scope("prototype")
@ConditionalOnClass(ObjectMapper.class)
@ConditionalOnBean(ObjectMapper.class)
public FactoryBean<JacksonTester<?>> jacksonTesterFactoryBean(ObjectMapper mapper) {
public FactoryBean<JacksonTester<?>> jacksonTesterFactoryBean(
ObjectMapper mapper) {
return new JsonTesterFactoryBean<JacksonTester<?>, ObjectMapper>(
JacksonTester.class, mapper);
}
}
@ConditionalOnClass(Gson.class)
private static class GsonJsonTestersConfiguration {
@Bean
@Scope("prototype")
@ConditionalOnClass(Gson.class)
@ConditionalOnBean(Gson.class)
public FactoryBean<GsonTester<?>> gsonTesterFactoryBean(Gson gson) {
return new JsonTesterFactoryBean<GsonTester<?>, Gson>(GsonTester.class, gson);
}
}
/**
* {@link FactoryBean} used to create JSON Tester instances.
*/
private class JsonTesterFactoryBean<T, M> implements FactoryBean<T> {
private static class JsonTesterFactoryBean<T, M> implements FactoryBean<T> {
private final Class<?> objectType;

Loading…
Cancel
Save