yookue / geo-location-spring-boot-starter

Geo location for spring boot starter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Geo Location Spring Boot Starter

Spring Boot application integrates GeoLocation quickly, to provide API for the GeoIP2 and GeoLite2 web services and databases.

Quickstart

  • Import dependencies
    <dependency>
        <groupId>com.yookue.springstarter</groupId>
        <artifactId>geo-location-spring-boot-starter</artifactId>
        <version>LATEST</version>
    </dependency>

By default, this starter will auto take effect, you can turn it off by spring.geo-location.enabled = false

  • Configure Spring Boot application.yml with prefix spring.geo-location
spring:
    geo-location:
        local-file:
            country-db: 'classpath:/ipaddr/GeoLite2-Country_20220701/GeoLite2-Country.mmdb'
            city-db: 'classpath:/ipaddr/GeoLite2-City_20220701/GeoLite2-City.mmdb'
            asn-db: 'classpath:/ipaddr/GeoLite2-ASN_20220701/GeoLite2-ASN.mmdb'
        remote-site:
            account-id: 999999
            license-key: 'foobar'

If you're using local-file only, comment remote-site node.

  • Configure your beans with a GeoLocationResolver bean by constructor or @Autowired/@Resource annotation, then you can resolve locations with it as following:
Method Return Method Name
String getCompositeAddress
String getCountryName
String getCityName

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

About

Geo location for spring boot starter

License:Apache License 2.0


Languages

Language:Java 100.0%