# ip2region-spring-boot-starter **Repository Path**: code4udd/ip2region-spring-boot-starter ## Basic Information - **Project Name**: ip2region-spring-boot-starter - **Description**: spring-boot-starter-ip2region - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2022-05-19 - **Last Updated**: 2022-05-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ip2region-spring-boot-starter Spring Boot Starter For ip2region ### 说明 > 基于 ip2region 的 Spring Boot Starter 实现 1. 最新IP数据下载地址: https://github.com/lionsoul2014/ip2region ### Maven ``` xml com.github.hiwepy ip2region-spring-boot-starter ${project.version} ``` ### Sample ```java import java.io.IOException; import javax.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @EnableIP2region @SpringBootApplication public class Application { @Autowired IP2regionTemplate template; @PostConstruct public void test() throws IOException { System.out.println(template.binarySearch("127.0.0.1")); System.out.println(template.binarySearch("127.0.0.1")); } public static void main(String[] args) throws Exception { SpringApplication.run(Application.class, args); } } ``` 如果使用外部IP数据,可自定义配置,参考如下: ```yaml ip2region: external: false index-block-size: 4096 total-header-size: 8192 location: classpath:ip2region/ip2region.db ```