java - NumberFormatException and TypeMismatchException for using propertyPlaceholderConfigurer in xml configuration -
i using list beingness initialized in spring.xml. need utilize propertyplaceholderconfigurer loose-couple initial values in pointlist.cfg.properties file.
this spring.xml code:
<bean id="parenttriangle" class="edu.akarimin.koushik.triangle" autowire="byname" init-method="myinit" destroy-method="cleanup"> <property name="pointlist"> <list> <ref bean="pointa" /> </list> </property> </bean> <bean id="triangle" class="edu.akarimin.koushik.triangle" parent="parenttriangle"> <property name="pointlist"> <list merge="true"> <ref bean="pointb" /> <ref bean="pointc" /> <ref bean="pointd" /> </list> </property> </bean> <bean id="pointa" class="edu.akarimin.koushik.point"> <property name="x" value="${pointa.pointx}" /> <property name="y" value="${pointa.pointy}" /> </bean> <bean id="pointb" class="edu.akarimin.koushik.point"> <property name="x" value="${pointb.pointx}" /> <property name="y" value="${pointb.pointy}" /> </bean> <bean id="pointc" class="edu.akarimin.koushik.point"> <property name="x" value="${pointc.pointx}" /> <property name="y" value="${pointc.pointy}" /> </bean> <bean id="pointd" class="edu.akarimin.koushik.point"> <property name="x" value="${pointd.pointx}" /> <property name="y" value="${pointd.pointy}" /> </bean> <bean id="pointe" class="edu.akarimin.koushik.point"> <property name="x" value="${pointe.pointx}" /> <property name="y" value="${pointe.pointy}" /> </bean> <bean class="org.springframework.beans.factory.config.propertyplaceholderconfigurer"> <property name="locations"> <list> <value>classpath:pointlist.cfg.properties</value> </list> </property> </bean>
triangle class code is:
package edu.akarimin.koushik; public class triangle{
private list<point> pointlist; public void draw(){ (point point : pointlist) { system.out.println("point= (" +point.getx()+ ","+point.gety()+")"); } public void myinit(){ system.out.println("myinit method called triangle"); } public void cleanup(){ system.out.println("cleanup method called triangle");
}
and main method is:
public class drawingapp { public static void main(string[] args) { applicationcontext context = new classpathxmlapplicationcontext("spring.xml"); triangle triangle = context.getbean("triangle", triangle.class); triangle.draw(); }
}
class point is:
public class point { private int x; private int y; public int getx() { homecoming x; } public void setx(int x) { this.x = x; } public int gety() { homecoming y; } public void sety(int y) { this.y = y; }
}
any ideas prepare problem ?
java xml spring spring-mvc
No comments:
Post a Comment