java - Requested Bean function generating error -
i've developed spring application overrides setterinjection on constructor injection. getter function generating error.
book.java package com.abc.xyz; public class book { private string name; public string getname() { return name; } public void setname(string name) { this.name = name; } public book(string name) { this.name=name; } } spring.xml: <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/
2001/xmlschema-instance" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="bookbean" class="com.abc.xyz.book"> <property name="name" value="abcd"> </property> <constructor-arg value="efgh"></constructor-arg> </bean> </beans> clientapp.java package com.abc.xyz; import org.springframework.context.applicationcontext; import org.springframework.context.support.classpathxmlapplicationcontext; public class clientapp {
applicationcontext context=new classpathxmlap
licationcontext("spring.xml"); book book=(book) context.getbean("bookbean"); book.getname();
}
Comments
Post a Comment