在XML配置中设置MarshallingMessageConverter中的marshalTo获取Invalid属性' marshalTo'

时间:2014-09-08 01:32:00

标签: java spring-jms

我试图创建一个MarshallingMessageConverter,这是我的XML:

<bean id="marshallingMessageConverter" class="org.springframework.jms.support.converter.MarshallingMessageConverter">
    <property name="marshaller" ref="marshaller" />
    <property name="unmarshaller" ref="marshaller" />
    <property name="marshalTo" value="MARSHAL_TO_TEXT_MESSAGE" />
</bean>

我收到以下错误:

Error setting property values; nested exception is
org.springframework.beans.NotWritablePropertyException: 
Invalid property 'marshalTo' of bean class
[org.springframework.jms.support.converter.MarshallingMessageConverter]: 
Bean property 'marshalTo' is not writable or has an invalid setter method. 
Does the parameter type of the setter match the return type of the getter?

这是因为MarshallingMessageConverter没有 getMarshalTo 方法,因此以这种方式设置它并不起作用吗?

看起来它应该是可能的,因为我发现https://jira.spring.io/browse/SWS-614,而其他人说他们有以下配置工作:

<bean id="marshaller" class="org.springframework.oxm.xstream.XStreamMarshaller"/>
<bean id="xstream" class="org.springframework.oxm.support.MarshallingMessageConverter"
  p:marshaller-ref="marshaller" p:unmarshaller-ref="marshaller" p:marshalTo="2"/>
<!--marshalTo=2 sets the marshaller to text message rather than bytes message-->

所以我觉得这可能是我想念的东西。我尝试在值中使用int,但这也不起作用。

我想使用XML配置,因为我使用的是Spring Integration,并且不想使用Java将bean从应用程序上下文中拉出来。

我使用的是Spring版本3.2.1.RELEASE。

1 个答案:

答案 0 :(得分:0)

我遗漏了一些东西......我正在查看

的文档
org.springframework.oxm.support.MarshallingMessageConverter

但我正在使用的是

org.springframework.jms.support.converter.MarshallingMessageConverter

,其方法为toTargetType()。

我不确定是否应删除我的问题或将其保留在此处,以防其他人做同样的事情。