I searched for the below problem, but couldn\'t find an answer.
I want to use spring\'s conversion service by writing my custom converter that implements org.spri
With spring > 4 it is no more necessary to implement an own derivation of the ConversionService. Initialize it in a @Configuration annotated class as follows:
@Configuration
public class ConversionServiceProvider
{
@Autowired
private MyConverterImpl myConverter;
@Bean
public ConversionService getConversionService()
{
ConversionServiceFactoryBean bean = new ConversionServiceFactoryBean();
bean.setConverters( getConverters() );
bean.afterPropertiesSet();
ConversionService object = bean.getObject();
return object;
}
private Set> getConverters()
{
Set> converters = new HashSet>();
converters.add( myConverter );
// add here more custom converters, either as spring bean references or directly instantiated
return converters;
}
}