JAVA - do some initialization when starting the project

Do initialization after the project starts

Many operations are intended to be performed after the project starts, such as:

  1. Write the sensitive words of the database into the memory
  2. Synchronize redis data
  3. Synchronize mysql data

The storage location of the startup class is as follows:
insert image description here

@EnableScheduling
@SpringBootApplication
public class FristApplication {

    public static void main(String[] args) {
        SpringApplication.run(FristApplication.class, args);
    }

}

@Slf4j
@Component
class ApplicationRunnerImpl implements ApplicationRunner {

    @Autowired
    private TaskHanderComponent taskHanderComponent;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("||==================================开始初始化==================================||");
        log.info("||==================================执行任务==================================||");

		// 把数据库的敏感词写进内存中
		// 同步redis数据
//        taskHanderComponent.syncSensitive();
    }
}

Guess you like

Origin blog.csdn.net/m0_67393827/article/details/126722803