spring项⽬启动执⾏特定⽅法1. ⽅法上加注解@PostConstruct
@Compant
public class InitDemo{
@PostConstruct
public void init(){
//项⽬启动就会执⾏这个⽅法
doSomething();
}
}
<bean id="InitDemo" class="InitDemo" scope="singleton" init-method="init">
</bean>
3.实现InitializingBean接⼝,重写afterPropertiesSet⽅法spring framework runtime
@Component
public class InitDemo implements InitializingBean {
@Override
public void afterPropertiesSet() throws Exception {

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。