|
@@ -1,7 +1,14 @@
|
|
|
package cn.qinys.ai.chatgpt.envetlistner;
|
|
package cn.qinys.ai.chatgpt.envetlistner;
|
|
|
|
|
|
|
|
|
|
+import lombok.val;
|
|
|
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
|
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
|
|
import org.springframework.context.ApplicationListener;
|
|
import org.springframework.context.ApplicationListener;
|
|
|
|
|
+import org.springframework.context.ConfigurableApplicationContext;
|
|
|
|
|
+import org.springframework.core.env.Environment;
|
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
+
|
|
|
|
|
+import java.net.InetAddress;
|
|
|
|
|
+import java.net.UnknownHostException;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* description:
|
|
* description:
|
|
@@ -9,10 +16,18 @@ import org.springframework.context.ApplicationListener;
|
|
|
* @author: tanlie
|
|
* @author: tanlie
|
|
|
* @date: 2024/10/1
|
|
* @date: 2024/10/1
|
|
|
*/
|
|
*/
|
|
|
-
|
|
|
|
|
|
|
+@Component
|
|
|
public class ApplicationStartEventListener implements ApplicationListener<ApplicationStartedEvent> {
|
|
public class ApplicationStartEventListener implements ApplicationListener<ApplicationStartedEvent> {
|
|
|
@Override
|
|
@Override
|
|
|
public void onApplicationEvent(ApplicationStartedEvent event) {
|
|
public void onApplicationEvent(ApplicationStartedEvent event) {
|
|
|
- System.err.println(event.getTimeTaken().getSeconds());
|
|
|
|
|
|
|
+ ConfigurableApplicationContext context = event.getApplicationContext();
|
|
|
|
|
+ try {
|
|
|
|
|
+ System.err.println(InetAddress.getLocalHost().getHostAddress());
|
|
|
|
|
+ } catch (UnknownHostException ignored) {
|
|
|
|
|
+ }
|
|
|
|
|
+ Environment env = context.getEnvironment();
|
|
|
|
|
+ System.err.println(env.getProperty("server.port"));
|
|
|
|
|
+ System.err.println(env.getProperty("spring.application.name"));
|
|
|
|
|
+ System.err.println(event.getTimeTaken().getSeconds());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|