spring - Bean definition is abstract Error on a Standalone Java application -
im trying create parentdao handle connection details standalone java application.
when run program error below
exception in thread "main" org.springframework.beans.factory.beanisabstractexception: error creating bean name 'parentdao': bean definition abstract
what doing wrong? know abstract class following examples used abstract classes. abstract parentdao class , 1 dry spring bean im totally lost specially on how on standalone application. , initialize applicationcontext , how.
below connection properties (bean.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.xsd"> <bean id="datasource" destroy-method="close" class="org.apache.commons.dbcp.basicdatasource"> <property name="driverclassname" value="oracle.jdbc.driver.oracledriver" /> <property name="url" value="jdbc:oracle:thin:@ipaddress:1521:habagat" /> <property name="username" value="username" /> <property name="password" value="password" /> </bean> <bean id="parentdao" class="com.mercury.dao.parentdao" abstract="true"> <property name="datasource" ref="datasource" /> </bean> <bean id="childdao" class="com.mercury.dao.childdaoimpl" parent="parentdao"/> </beans>
below main method
public static void main(string[] args) { applicationcontext context = new classpathxmlapplicationcontext( "beans.xml"); parentdao parentdao = (parentdao) context.getbean("parentdao"); }
and parent dao class
public abstract class parentdao<t> extends jdbcdaosupport { public abstract void insert(t object) throws exception; public abstract void delete(int id) throws exception; public abstract void update(t object) throws exception; public abstract t select(int id) throws exception; }
my service
public class myservice { childdao childdao; public string getchildrencount() { return int totalcount = childdao.getrecordcount(); } }
well, parent dao is abstract. why try pull bean out of context? want childdao bean.
Comments
Post a Comment