Spring Boot application integrates IP2Region
quickly, to provide abilities to resolve IP address to region.
- Import dependencies
<dependency>
<groupId>com.yookue.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.yml
with prefixspring.ip-region
spring:
ip-region:
discard-lan: true
region-db: 'classpath:/ipaddr/Ip2Region_20240228/ip2region.xdb'
- Configure your beans with a
IpRegionResolver
bean by constructor or@Autowired
/@Resource
annotation, then you can resolve locations with it as following:
Method Return | Method Name |
---|---|
String | getCompositeAddress |
String | getRegionOutcome |
- Github: https://github.com/yookue/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 Yookue to support the development.
- Yookue: https://yookue.com