public class PersonServiceBean implements IPersonService {
public void init(){
System.out.println("我是初始化函数");
}
public PersonServiceBean(){
System.out.println("我是构造函数");
}
public void Save(){
System.out.println("save方法");
}
public void cleanup(){
System.out.println("cleanup方法");
}
}
<bean id="personService"
class="cn.itcast.service.impl.PersonServiceBean"
init-method="init" destroy-method="cleanup"/>
@Test public void instanceSpring(){
ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext("beans.xml");
IPersonService ipersonService=(IPersonService)ctx.getBean("personService");
ctx.close();