如何使用Spring在不遵循Java bean规范的setter中注入对象?

Gui*_*ume 7 java spring inversion-of-control

我试图一起使用Springwx-xmlrpc.问题是XmlRpcClient有一个不遵循Java Bean规范的setConfig()方法:setter和getter不使用相同的Class.所以当我有以下context.xml时Spring抱怨:

<bean id="xmlRpcClient" class="org.apache.xmlrpc.client.XmlRpcClient">
    <property name="config">
        <bean class="org.apache.xmlrpc.client.XmlRpcClientConfigImpl">
            <property name="serverURL" value="http://example.net" />
        </bean>
    </property>
</bean>
Run Code Online (Sandbox Code Playgroud)

它说:Bean属性'config'不可写或具有无效的setter方法.setter的参数类型是否与getter的返回类型匹配?

有没有办法覆盖它?我知道我可以为这个bean写一个特定的工厂,但在我看来,这不是我最后一次发现这种问题.我使用质量可疑的遗留代码工作很多...能够使用Spring XML配置将是一个很大的帮助!

mP.*_*mP. 9

为该类编写FactoryBean并让它调用正确的setter.