| | |
| | | package com.iailab.module.system.job.config; |
| | | |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.net.InetAddress; |
| | | import java.net.UnknownHostException; |
| | | |
| | | /** |
| | | * 服务器资源监控配置文件 |
| | | */ |
| | | @Configuration |
| | | public class ServerInfoConfiguration { |
| | | |
| | | public static String hostName; |
| | | |
| | | public static String hostIp; |
| | | |
| | | @PostConstruct |
| | | public void initServerInfo() throws UnknownHostException { |
| | | System.out.println("初始化获取服务器信息initServerInfo..."); |
| | | // 获取本地主机对象 |
| | | InetAddress localHost = InetAddress.getLocalHost(); |
| | | // 获取主机名 |
| | | hostName = localHost.getHostName(); |
| | | // 获取IP地址 |
| | | hostIp = localHost.getHostAddress(); |
| | | } |
| | | |
| | | } |
| | | //package com.iailab.module.system.job.config; |
| | | // |
| | | //import org.springframework.context.annotation.Configuration; |
| | | // |
| | | //import javax.annotation.PostConstruct; |
| | | //import java.net.InetAddress; |
| | | //import java.net.UnknownHostException; |
| | | // |
| | | ///** |
| | | // * 服务器资源监控配置文件 |
| | | // */ |
| | | //@Configuration |
| | | //public class ServerInfoConfiguration { |
| | | // |
| | | // public static String hostName; |
| | | // |
| | | // public static String hostIp; |
| | | // |
| | | // @PostConstruct |
| | | // public void initServerInfo() throws UnknownHostException { |
| | | // System.out.println("初始化获取服务器信息initServerInfo..."); |
| | | // // 获取本地主机对象 |
| | | // InetAddress localHost = InetAddress.getLocalHost(); |
| | | // // 获取主机名 |
| | | // hostName = localHost.getHostName(); |
| | | // // 获取IP地址 |
| | | // hostIp = localHost.getHostAddress(); |
| | | // } |
| | | // |
| | | //} |