写一个类继承ApplicationListener,可以直接引用下述代码,然后调用相应的方法。

package com.linewell.system;

import com.linewell.cache.ApplicationData;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

@Component
public class InitializationProcessor implements ApplicationListener<ContextRefreshedEvent> {


    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        if (contextRefreshedEvent.getApplicationContext().getParent() == null) {
            System.out.println("run onApplicationEvent method");
//dosomething } } }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2022-03-03
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2021-06-28
  • 2022-12-23
  • 2023-03-14
  • 2021-05-23
  • 2021-05-28
  • 2021-10-04
相关资源
相似解决方案