xml形式
package cn.xy;
public class studentserviceimpl
{
private studentdao studentdao;
public void init()
{
system.out.println("正在执行初始化的init方法");
}
public void save(student s)
studentdao.insert(s);
public void destory()
system.out.println("正在执行销毁之前的destory方法");
public studentdao getstudentdao()
return studentdao;
public void setstudentdao(studentdao studentdao)
this.studentdao = studentdao;
}
<bean id="studentdao" class="cn.xy.studentdao" />
<bean id="studentservice" class="cn.xy.studentserviceimpl" init-method="init" destory-method="destory">
<property name="studentdao" ref="studentdao">
</bean>
注解形式
@postconstruct
@predestory
@resource