package com.summergao.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import java.net.InetAddress;
import java.net.UnknownHostException;
@Configuration
public class ServerConfig {
@Value("${tomcat.port}")
private Integer port;
@Value("${tomcat.contextPath}")
private String contextPath;
public String getUrl() {
InetAddress address = null;
try {
address = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
e.printStackTrace();
}
return "http://" + address.getHostAddress() + ":" + port + "/" + contextPath;
}
}