XML配置
在spring的配置文件中,配置如下的bean
<bean id="initClient" class="com.test.bi.support.util.ClientInit" init-method="init"/>
- 实现ServletContextAware, InitializingBean接口
在spring的配置文件中,配置如下的bean
<bean id="initClient" class="com.test.bi.support.util.ClientInit"/>
所要初始化的方法实现ServletContextAware, InitializingBean这两个接口,重写afterPropertiesSet()、setServletContext()方法,并在setServletContext()方法中写入要初始化的方法
- 注解方式
使用注解只需要在方法名上添加@PostConstruct。