Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deprecation warning from spring

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.

like image 925
valodzka Avatar asked Dec 08 '12 11:12

valodzka


1 Answers

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>
like image 196
valodzka Avatar answered Oct 03 '22 07:10

valodzka