From c2e9442d733d0e957fd4eb41659960536e7bf2b8 Mon Sep 17 00:00:00 2001 From: reine-ishyanami <2402979195@qq.com> Date: Sun, 10 Sep 2023 14:54:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=90=AF=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/ApplicationStartedListener.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/com/reine/imagehost/config/ApplicationStartedListener.java diff --git a/src/main/java/com/reine/imagehost/config/ApplicationStartedListener.java b/src/main/java/com/reine/imagehost/config/ApplicationStartedListener.java new file mode 100644 index 0000000..640becb --- /dev/null +++ b/src/main/java/com/reine/imagehost/config/ApplicationStartedListener.java @@ -0,0 +1,26 @@ +package com.reine.imagehost.config; + +import jakarta.annotation.Nonnull; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.event.ApplicationStartedEvent; +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +/** + * @author reine + */ +@Component +@Slf4j +public class ApplicationStartedListener implements ApplicationListener { + + @Value("${server.port}") + private int port; + + @Override + public void onApplicationEvent(@Nonnull ApplicationStartedEvent event) { + // 在应用程序启动后执行的代码 + log.info("Knife4j UI: http://localhost:{}/doc.html", port); + // 添加您的自定义逻辑在这里 + } +}