我正在使用Java中的GeoIP2将IP地址转换为maxmind数据库中的位置信息。
我的java代码:
try {
ClassLoader classLoader = getClass().getClassLoader();
File database = new File(classLoader.getResource("GeoLite2-City.mmdb").getFile());
DatabaseReader reader = new DatabaseReader.Builder(database).build();
InetAddress ipAddress = InetAddress.getByName(ip);
CityResponse response = reader.city(ipAddress);
City city = response.getCity();
...
} catch (UnknownHostException e) {
logger.logError(getClass(), "getGeoIp", " transactionId:" + transactionId + " > " + e.getMessage(), null);
} catch (IOException e) {
logger.logError(getClass(), "getGeoIp", " transactionId:" + transactionId + " > " + e.getMessage(), null);
} catch (GeoIp2Exception e) {
logger.logError(getClass(), "getGeoIp", " transactionId:" + transactionId + " > " + e.getMessage(), null);
}当我构建我的阅读器时,我得到了java.lang.reflect.InvocationTargetException异常。我认为杰克逊版本(2.5.3)与geoip2不兼容。但我不能修复。
我的依赖版本是:
<dependency>
<groupId>com.maxmind.geoip2</groupId>
<artifactId>geoip2</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency> 发布于 2017-03-02 21:03:14
使用2.3.0版本的geoip2。
<dependency>
<groupId>com.maxmind.geoip2</groupId>
<artifactId>geoip2</artifactId>
<version>2.3.0</version>
</dependency>2.8.1使用较新版本的Jackson,导致与您的Jackson依赖冲突。
https://stackoverflow.com/questions/42553167
复制相似问题