My Bean.xml has
<bean id = "triangle" class="com.cg.collectionss.Triangle">
<property name="listpoints">
<list>
<ref bean ="point"/>
<ref bean ="point1"/></list>
</property>
</bean>
<bean id="point" class="com.cg.collectionss.Point">
<property name="x" value="hello"></property>
<property name="y" value="world"></property>
package com.cg.collectionss;
import java.util.List;
public class Triangle
{
private List<Point> listpoints;
public void setListPoints(List<Point> points)
{
listpoints= points;
}
public List<Point> getListPoints()
{
return listpoints;
}
}
错误:由以下原因引起:org.springframework.beans.NotWritablePropertyException:Bean类[com.cg.collectionss.Triangle]的无效属性“ listpoints”:Bean属性“ listpoints”不可写,或者具有无效的setter方法。您是说“ listPoints”吗? 在org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:243) 在org.springframework.beans.AbstractNestablePropertyAccessor.processLocalProperty(AbstractNestablePropertyAccessor.java:426) 在org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:278) 在org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:266) 在org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:97) 在org.springframework.beans.AbstractPropertyAccessor.setPrope ................
当我将Bean.xml
中的属性名称更改为ListPoints
时,得到了预期的输出。为什么不能将属性名称listpoints
作为属性名称?。