[Java] 纯文本查看 复制代码
package com.ay.service.impl;
import com.ay.service.AccountService;
public class AccountServiceImpl implements AccountService {
@Override
public void saveAccount() {
System.out.println("方法创建成功了");
}
public AccountServiceImpl() {
System.out.println("对象开始创建了");
}
public void init(){
System.out.println("对象初始化");
}
public void destroy(){
System.out.println("对象销毁");
}
}
[Java] 纯文本查看 复制代码
package com.ay.ui;
import com.ay.service.AccountService;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Client {
public static void main(String[] args) {
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");
AccountService as = (AccountService)ac.getBean("accountService");
as.saveAccount();
ac.close();
}
}