Springboot中獲取本機IP、端口號和Context-path,項目啓動後輸出路徑

獲取IP 直接使用InetAddress:java String IP = InetAddress.getLocalHost().getHostAddress(); 獲取端口號 1.使用配置文件獲取(可能返回爲空)web Environment env = context.getEnvironment(); String port = env.getProperty("server.port");
相關文章
相關標籤/搜索