Skip to content

yookue/geo-location-spring-boot-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages