Spring Boot application integrates IP2Region quickly, to provide abilities to resolve IP address to region.
- Import dependencies
<dependency>
<groupId>cn.unikue.springstarter</groupId>
<artifactId>ip-region-spring-boot-starter</artifactId>
<version>LATEST</version>
</dependency>By default, this starter will auto take effect, you can turn it off by
spring.ip-region.enabled = false
- Configure Spring Boot
application.ymlwith prefixspring.ip-region
spring:
ip-region:
discard-lan: true
region-db: 'classpath:/ipaddr/Ip2Region_20240228/ip2region.xdb'- Configure your beans with a
IpRegionResolverbean by constructor or@Autowired/@Resourceannotation, then you can resolve locations with it as following:
| Method Return | Method Name |
|---|---|
| String | getCompositeAddress |
| String | getRegionOutcome |
- Github: https://github.com/unikueltd/ip-region-spring-boot-starter
- Ip2region github: https://github.com/lionsoul2014/ip2region
- jdk 17+
This project is under the Apache License 2.0
See the NOTICE.txt file for required notices and attributions.
You like this package? Then donate to us to support the development.
Beijing Unikue Network Technology Ltd.
- Unikue: https://unikue.cn