1. 在配置文件中通过指定init-method属性来完成
如: <bean id="HelloWorld" class="com.gc.action.HelloWorld" init-method="init">
</bean>
2. 实现org.springframework.beans.factory.InitialingBean接口, 重写afterPropertiesSet()方法
两种方式实现的功能一样,但推荐使用第一种方式,因为第一种方式没有把代码耦合于spring中.