Spring整理8 -- 初始化函数和消亡函数的使用
配置文件:
?
?程序:
package dbconf; public class Conf { //你还可以定义初始化函数(不能有参数,命名随意) public void init(){ System.out.println("初始化函数"); } public void destroy(){ System.out.println("消亡函数"); } private String driverClassName; private String url; public String getDriverClassName() { return driverClassName; } public void setDriverClassName(String driverClassName) { this.driverClassName = driverClassName; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public void printInfo(){ System.out.println(this.driverClassName); System.out.println(this.url); }}?