Attualmente stiamo utilizzando Spring Framework e si utilizza XML seguente: -ConversionNotSupportedException quando si utilizza RuntimeBeanRefrence per un elenco di oggetti
<bean id="A" class="com.foo.baar.A" >
<property name="attributes">
<set value-type="com.foo.bar.B">
<ref bean="X" />
<ref bean="Y" />
</set>
</property>
</bean>
<bean id="X" class="com.foo.bar.X" />
<bean id="Y" class="com.foo.bar.Y" />
dove la classe X e la classe Y estendere la classe B
classe A ha setter come segue: -
public void setAttributes(List<B> attributes) {
this.attributes = attributes;
}
Ora, devo eliminare l'XML sopra e io pongo i fagioli programmaticamente come segue: -
012.List<Object> beanRefrences = new ArrayList<Object>();
for(String attribute : attributes) {
Object beanReference = new RuntimeBeanReference(attribute);
beanRefrences.add(beanReference);
}
mutablePropertyValues.add(propertyName, beanRefrences);
Con codice di cui sopra, sto ottenendo seguente errore: -
nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.ArrayList' to required type 'java.util.List' for property 'attributes';
nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.beans.factory.config.RuntimeBeanReference] to required type [com.foo.bar.B] for property 'attributes[0]': no matching editors or conversion strategy found
qualcuno può darmi indicazioni su come farlo funzionare correttamente?
Sembra come si imposta un'istanza di 'RuntimeBeanReference' dove si dovrebbe impostare un'istanza di' B'. – zeroflagL
@DexterMorgan, hai fatto funzionare? – whiskeysierra