spring mvc - Failed to convert property value of type 'com.siri.espc.dao.Point' to required type 'java.awt.Point' for property 'pointA'; -
apr 14, 2017 7:42:19 pm org.springframework.context.support.classpathxmlapplicationcontext preparerefresh info: refreshing org.springframework.context.support.classpathxmlapplicationcontext@3d71d552: startup date [fri apr 14 19:42:19 ist 2017]; root of context hierarchy apr 14, 2017 7:42:19 pm org.springframework.beans.factory.xml.xmlbeandefinitionreader loadbeandefinitions info: loading xml bean definitions class path resource [spring.xml] apr 14, 2017 7:42:19 pm org.springframework.context.support.classpathxmlapplicationcontext refresh warning: exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.beancreationexception: error creating bean name 'triangle' defined in class path resource [spring.xml]: initialization of bean failed; nested exception org.springframework.beans.conversionnotsupportedexception: failed convert property value of type 'com.siri.espc.dao.point' required type 'java.awt.point' property 'pointa'; nested exception java.lang.illegalstateexception: cannot convert value of type 'com.siri.espc.dao.point' required type 'java.awt.point' property 'pointa': no matching editors or conversion strategy found exception in thread "main" org.springframework.beans.factory.beancreationexception: error creating bean name 'triangle' defined in class path resource [spring.xml]: initialization of bean failed; nested exception org.springframework.beans.conversionnotsupportedexception: failed convert property value of type 'com.siri.espc.dao.point' required type 'java.awt.point' property 'pointa'; nested exception java.lang.illegalstateexception: cannot convert value of type 'com.siri.espc.dao.point' required type 'java.awt.point' property 'pointa': no matching editors or conversion strategy found @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:564) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:483) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:306) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:230) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:302) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:197) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:761) @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:866) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:542) @ org.springframework.context.support.classpathxmlapplicationcontext.(classpathxmlapplicationcontext.java:139) @ org.springframework.context.support.classpathxmlapplicationcontext.(classpathxmlapplicationcontext.java:83) @ co.javabrains.springdemo.drawingapp.main(drawingapp.java:26) caused by: org.springframework.beans.conversionnotsupportedexception: failed convert property value of type 'com.siri.espc.dao.point' required type 'java.awt.point' property 'pointa'; nested exception java.lang.illegalstateexception: cannot convert value of type 'com.siri.espc.dao.point' required type 'java.awt.point' property 'pointa': no matching editors or conversion strategy found @ org.springframework.beans.abstractnestablepropertyaccessor.convertifnecessary(abstractnestablepropertyaccessor.java:605) @ org.springframework.beans.abstractnestablepropertyaccessor.convertforproperty(abstractnestablepropertyaccessor.java:617) @ org.springframework.beans.beanwrapperimpl.convertforproperty(beanwrapperimpl.java:216) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.convertforproperty(abstractautowirecapablebeanfactory.java:1577) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.applypropertyvalues(abstractautowirecapablebeanfactory.java:1536) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.populatebean(abstractautowirecapablebeanfactory.java:1276) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:553) ... 11 more caused by: java.lang.illegalstateexception: cannot convert value of type 'com.siri.espc.dao.point' required type 'java.awt.point' property 'pointa': no matching editors or conversion strategy found @ org.springframework.beans.typeconverterdelegate.convertifnecessary(typeconverterdelegate.java:306) @
<?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="com.siri.espc.dao.triangle"> <property name="pointa" ref="point1"/> <property name="pointb" ref="point2"/> <property name="pointc" ref="point3"/> </bean> <!-- <property name="type" value="equilateral"> </property> <constructor-arg value="equilateral"></constructor-arg> <constructor-arg value="20"></constructor-arg> <constructor-arg type ="java.lang.string" value="equilateral"></constructor-arg> <constructor-arg type="int" value="20"></constructor-arg> --> <bean id="point1" class="com.siri.espc.dao.point"> <property name="x" value="0"></property> <property name="y" value="0"></property> </bean> <bean id="point2" class="com.siri.espc.dao.point"> <property name="x" value="20"></property> <property name="y" value="0"></property> </bean> <bean id="point3" class="com.siri.espc.dao.point"> <property name="x" value="20"></property> <property name="y" value="0"></property> </bean> </beans>
package com.siri.espc.dao; public class point { private int x; private int y; private int z; public int getx() { return x; } public void setx(int x) { this.x = x; } public int gety() { return y; } public void sety(int y) { this.y = y; } public int getz() { return z; } public void setz(int z) { this.z = z; } }
package co.javabrains.springdemo; import org.springframework.beans.beansexception; import org.springframework.beans.factory.beanfactory; import org.springframework.beans.factory.nosuchbeandefinitionexception; import org.springframework.beans.factory.xml.xmlbeanfactory; import org.springframework.context.applicationcontext; import org.springframework.context.support.classpathxmlapplicationcontext; import org.springframework.core.io.filesystemresource; import com.siri.espc.dao.triangle; public class drawingapp { private static applicationcontext aobj; public static void main(string[] args) { /*triangle tobj = new triangle(); //tobj.draw(); //beanfactory bobj = new xmlbeanfactory(new filesystemresource("spring.xml")); //triangle tobj = (triangle) bobj.getbean("triangle"); //tobj.draw();*/ aobj = new classpathxmlapplicationcontext("spring.xml"); triangle triobj = (triangle) aobj.getbean("triangle"); triobj.draw(); } }
org.springframework.beans.abstractnestablepropertyaccessor.convertifnecessary(abstractnestablepropertyaccessor.java:590) ... 17 more
Comments
Post a Comment