【发布时间】:2016-06-19 18:03:28
【问题描述】:
我正在尝试将 MaxMind java 库与 ColdFusion 一起使用。
我开始在 MaxMind 官方网站上转换此示例代码:
// A File object pointing to your GeoIP2 or GeoLite2 database
File database = new File("/path/to/GeoIP2-City.mmdb");
// This creates the DatabaseReader object, which should be reused across
// lookups.
DatabaseReader reader = new DatabaseReader.Builder(database).build();
InetAddress ipAddress = InetAddress.getByName("128.101.101.101");
// Replace "city" with the appropriate method for your database, e.g.,
// "country".
CityResponse response = reader.city(ipAddress);
Country country = response.getCountry();
我试过的是:
var file = "pathto\maxmind\GeoLite2-City.mmdb";
var db = createObject("java","java.io.File").init(file);
var mm = createObject("java", "com.maxmind.geoip2.DatabaseReader")
.Builder(db)
.build();
dump(c);abort;
我收到了这个错误:
Type: java.lang.NoSuchMethodException
Messages: No matching Method for Builder(java.io.File) found
for com.maxmind.geoip2.DatabaseReader
我做错了什么?
【问题讨论】:
-
旁注,'file' 是 CF 中的保留字,因此您可能需要选择不同的变量名以避免意外问题。
-
是的,我已经即时发布了代码,仅作为示例。我的真实代码有点不同。谢谢
标签: java coldfusion railo maxmind lucee