I want to create a Spring ConversionService
with custom Converter
s, but the return value of ConversionServiceFactoryBean#getObject
is null
. See example:
@Bean
@Autowired
public ConversionService conversionService(Set<Converter<?, ?>> converters) {
final ConversionServiceFactoryBean factory = new ConversionServiceFactoryBean();
factory.setConverters(converters);
return checkNotNull(
factory.getObject(),
"conversionService must not be null.");
}
checkNotNull
throws a NullPointerException
. The converters
are injected as expected. Why does the factory return null
? How can I fix that?