4
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
     <bean id="triangle" class="bean.Trinangle">
         <property name="points">
             <list>
                 <ref bean="point1"/>
                 <ref bean="point2"/>
                 <ref bean="point3"/>
             </list>
         </property>
     </bean>

     <bean id= "point1" class="bean.Point">
         <property name="x" value="10"/>
         <property name="y" value="20"/>
     </bean>

     <bean id= "point2" class="bean.Point">
         <property name="x" value="10"/>
         <property name="y" value="20"/>
     </bean>

     <bean id= "point3" class="bean.Point">
         <property name="x" value="10"/>
         <property name="y" value="20"/>
     </bean>
</beans>              

Question: this is my XML file.on the 6 th line im getting error"he content of element type "property" must match "(description?,meta*,(bean|ref|idref|value|null|list|set|map| props)?)".".

Javasick
  • 2,753
  • 1
  • 23
  • 35
  • so you have something like setPoints(List points) on your bean? If yes, have a look at this: http://stackoverflow.com/questions/2416056/how-to-define-a-list-bean-in-spring – Raphael Roth Mar 21 '16 at 07:27

2 Answers2

0

I think you are not actually creating a List (if that whats setPoints expects). Try something like this (taken from How to define a List bean in Spring?):

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">


 <beans>

 <bean id= "point1" class="bean.Point">
   <property name="x" value="10"/>
   <property name="y" value="20"/>
 </bean>
 <bean id= "point2" class="bean.Point">
   <property name="x" value="10"/>
   <property name="y" value="20"/>
 </bean>
 <bean id= "point3" class="bean.Point">
   <property name="x" value="10"/>
   <property name="y" value="20"/>
 </bean>

<util:list id="pointList" value-type="bean.Point">
    <value>point1</value>
    <value>point2</value>
    <value>point3</value>
</util:list>


 <bean id="triangle" class="bean.Trinangle">
   <property name="points" value="pointList" />
 </bean>

 <bean id= "point1" class="bean.Point">
   <property name="x" value="10"/>
   <property name="y" value="20"/>
 </bean>
 <bean id= "point2" class="bean.Point">
   <property name="x" value="10"/>
   <property name="y" value="20"/>
 </bean>
 <bean id= "point3" class="bean.Point">
   <property name="x" value="10"/>
   <property name="y" value="20"/>
 </bean>
</beans>
Community
  • 1
  • 1
Raphael Roth
  • 26,751
  • 15
  • 88
  • 145
0

Your version is mismatched with xml version, you must try below doctype declaration.

<beans xmlns=" http://www.springframework.org/schema/beans "
       xmlns:xsi=" http://www. W3.org/2001/XMLSchema-instance "
       xmlns:util=" http://www.springframework.org/schema/util "
       xsi:schemaLocation=" http://www.springframework.org/schema/beans
           http:/ /www.springframework.org/schema/beans/spring-beans-3.0.xsd " default-lazy-init="true">
Simply Ged
  • 8,250
  • 11
  • 32
  • 40
Ria Sachdeva
  • 113
  • 6