I have this converter to trim whitespaces
@Component
public class StringTrimmingConverter implements Converter<String, String> {
@Override
public String convert(String source) {
return source.trim();
}
}
But I'm getting this error upon startup of the web app project...
Caused by: java.lang.IllegalArgumentException: Unable to the determine sourceType and targetType which your Converter converts between; declare these generic types. at org.springframework.core.convert.support.GenericConversionService.addConverter(GenericConversionService.java:95) at org.springframework.core.convert.support.ConversionServiceFactory.registerConverters(ConversionServiceFactory.java:50) at org.springframework.context.support.ConversionServiceFactoryBean.afterPropertiesSet(ConversionServiceFactoryBean.java:69) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) ... 21 more
Here's the configuration
<mvc:annotation-driven validator="validator" conversion-service="conversionService"/>
<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
<property name="converters">
<set>
<bean class="ph.com.xxx.yyy.converter.StringTrimmingConverter"/>
</set>
</property>
</bean>
@Component
– Kevin BowersoxList
instead of aSet
in the configuration? – Kevin Bowersox