I have such xml:
<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
<property name="converters">
<list>
<bean class="converters.AddressToStringConverter" />
<bean class="converters.StringToAddressConverter" />
</list>
</property>
</bean>
It configures converters without problems.
But then this code fails to make the same:
@Configuration
public class ConversionConfiguration {
@Bean
public ConversionService getConversionService() {
ConversionServiceFactoryBean bean = new ConversionServiceFactoryBean();
bean.setConverters(getConverters());
bean.afterPropertiesSet();
ConversionService object = bean.getObject();
return object;
}
private Set<Converter> getConverters() {
Set<Converter> converters = new HashSet<Converter>();
converters.add(new AddressToStringConverter());
converters.add(new StringToAddressConverter());
return converters;
}
}
This piece of configuration gets scanned by context - I checked it with debugger. Where could be the problem?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…