获取applicationContext
implements ApplicationContextAware @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; }
开启和销毁
implements InitializingBean, DisposableBean @Override public void afterPropertiesSet() throws Exception { System.out.println("启动了"); } @Override public void destroy() throws Exception { System.out.println("销毁了"); }