春天的弃用警告 [英] Deprecation warning from spring

查看:265
本文介绍了春天的弃用警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序启动时,我收到以下警告消息(数十次):

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。

Spring version 2.5.6.

推荐答案

添加自定义编辑器修复警告:

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);
   }
}

在配置中:

<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>

这篇关于春天的弃用警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆