1

I want to configure AnnotationMethodHandlerExceptionResolver by adding jackson message converter. The problem is that I have already configured message converters in <mvc:message-converters> by creating a bean, and I can't reference it in AnnotationMethodHandlerExceptionResolver neither use ref in <mvc:message-conferters>

<mvc:annotation-driven>
    <mvc:message-converters register-defaults="false">
        <bean id="mappingJackson2" class="pl.styall.scylla.json.config.CustomMappingJackson2">
            <property name="objectMapper" ref="jacksonObjectMapper" />
        </bean>
    </mvc:message-converters>
</mvc:annotation-driven>

<bean id="outboundExceptionAdapter"
    class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver">
    <property name="messageConverters">
        <list>
            <ref bean="mappingJackson2" />
        </list>
    </property>
</bean>

I could define two beans one for <mvc:message-converters> and AnnotationMethodHandlerExceptionResolver, but it is probably not the best idea. Is there other way to do this?

user1137146
  • 285
  • 1
  • 3
  • 14
  • As an aside, in 3.1.2 and later your custom class might no longer be needed; `org.springframework.http.converter.json.MappingJackson2HttpMessageConverter` might work as well. – Arjan Oct 01 '12 at 13:43
  • The reason why I created a custom class http://stackoverflow.com/a/11961094/1137146 – user1137146 Oct 06 '12 at 10:21

1 Answers1

0

This is not supported yet, but it is on the 3.2 backlog. So it might be supported in 3.2.

See Add support for <ref> in addition to <bean> for <mvc:message-converters> for the Spring feature request.

Arjan
  • 22,808
  • 11
  • 61
  • 71