Skip to content

yookue/ip-region-spring-boot-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IP Region Spring Boot Starter

Spring Boot application integrates IP2Region quickly, to provide abilities to resolve IP address to region.

Quickstart

  • 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 prefix spring.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

Document

Requirement

  • jdk 17+

License

This project is under the Apache License 2.0

See the NOTICE.txt file for required notices and attributions.

Donation

You like this package? Then donate to Yookue to support the development.

Website