nesnelerin bir listesi için RuntimeBeanRefrence kullanarak ve aşağıdaki XML kullanırken: - sınıfı X ve sınıf-YConversionNotSupportedException şu anda yay çerçevesi kullanan
sınıf A olarak ayarlayıcı sahip B sınıfı uzanan
<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" />
aşağıdaki gibidir: -
public void setAttributes(List<B> attributes) {
this.attributes = attributes;
}
Şimdi, yukarıdaki XML ortadan kaldırmak için var ve şu şekilde programlama yoluyla fasulye kuruyorum: -
Yukarıdaki kod ileList<Object> beanRefrences = new ArrayList<Object>();
for(String attribute : attributes) {
Object beanReference = new RuntimeBeanReference(attribute);
beanRefrences.add(beanReference);
}
mutablePropertyValues.add(propertyName, beanRefrences);
, ben hata aşağıdaki alıyorum: -
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
kimse bana nasıl doğru çalışması için işaretçiler verebilir misiniz?
görünüyor: Bir
ManagedList
kullanmak gerekir. – zeroflagL@DexterMorgan, işe yaradı mı? – whiskeysierra