package com.yutou.bilibili.Tools; import com.yutou.bilibili.services.LiveDatabasesService; import com.yutou.bilibili.services.LiveVideoDownloadService; import com.yutou.bilibili.services.SystemService; import com.yutou.common.utils.Log; import jakarta.annotation.Resource; import org.jetbrains.annotations.NotNull; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextClosedEvent; import org.springframework.stereotype.Component; @Component public class ApplicationClose implements ApplicationListener { @Resource SystemService systemConfigService; @Resource LiveVideoDownloadService videoService; @Resource LiveDatabasesService databasesService; @Override public void onApplicationEvent(@NotNull ContextClosedEvent contextClosedEvent) { Log.i("服务结束"); systemConfigService.stop(); videoService.stopAll(); databasesService.closeAll(); } }