HttpMessageNotWritableException未找到JavassistLazyInitializer的序列化程序

时间:2015-10-09 13:33:11

标签: spring-mvc jackson

我有例外

org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) )

但我已经禁用了SerializationFeature.FAIL_ON_EMPTY_BEANS功能。

这是我的servlet-context.xml

    <beans:bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
        <beans:property name="messageConverters">
            <beans:list>
                <beans:ref bean="jsonMessageConverter"/>
            </beans:list>
        </beans:property>
    </beans:bean>

    <!-- Configure bean to convert JSON to POJO and vice versa -->
    <beans:bean id="jsonMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
        <beans:property name="objectMapper" ref="jacksonObjectMapper" />
    </beans:bean>

    <beans:bean id="jacksonObjectMapper" class="controllers.MyJsonMapper"></beans:bean>

自定义ObjectMapper

public class MyJsonMapper extends ObjectMapper {

    public MyJsonMapper() {
        this.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    }

}

我做错了什么?

0 个答案:

没有答案