Deprecation warning from spring
java, spring, warnings
Solution
Adding custom editor fixed warning:
public final class EnumPropertyEditor extends PropertyEditorSupport {
public EnumPropertyEditor() {
}
@Override
public String getAsText() {
return (String) getValue();
}
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(text);
}
}
In config:
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.lang.Enum">
<bean class="package.EnumPropertyEditor">
</bean>
</entry>
</map>
</property>
</bean>
Problem
While applications starts I'm getting following warning messages (dozens of times): ``` Dec 08, 2012 5:10:41 PM org.springframework.beans.TypeConverterDelegate findDefaultEditor WARNING: PropertyEditor [sun.beans.editors.EnumEditor] found through deprecated global PropertyEditorManager fallback - consider using a more isolated form of registration, e.g. on the BeanWrapper/BeanFactory! ``` Google shows that it's very common message, but unfortunatelly doesn't show why it happens. How can I avoid these warnings? Spring version 2.5.6.