参考:
(1)Java根据IP离线获取国家、省市区和经纬度:
https://kangyonggan.com/article/149
我:
import com.maxmind.geoip2.DatabaseReader;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.File;
import java.net.InetAddress;
@Log4j2
@Component
public class GeoLiteUtil
{
public interface LANG {
String EN = "en";
String ZH = "zh-CN";
}
public interface COUNTRY {
String ENGLAND = "England";
String CHINA = "China";
}
/**
* GeoLite2-Country.mmdb 离线数据库文件 的路径
*/
@Value(value = "${geoLite.path}")
private String IP_DB_PATH = "C:\\Users\\Administrator\\Desktop\\GeoLite2-Country.mmdb";