Google Maps Services Java客户端冻结WebApp

时间:2017-08-11 11:58:27

标签: java google-maps google-places-api

我想获取客户从Google Places API输入的位置名称的纬度和经度。执行冻结在第二行。

    try {
            GeoApiContext context = new GeoApiContext.Builder().apiKey("MY_API_KEY").build();
            PlaceDetails placeDetails = PlacesApi.placeDetails(context, "Nairobi").await();
            double lat = placeDetails.geometry.location.lat;
            double lng = placeDetails.geometry.location.lng;
        } catch (ApiException | InterruptedException | IOException apiException) {
        apiException.printStackTrace(System.out);
    }

我得到了以下堆栈跟踪,但我无法确定根本原因,因为我运行的示例在提供的测试中是最简单的。

我的应用程序中包含的库是:

  1. 谷歌地图服务-0.2.1.jar
  2. GSON-2.8.1.jar
  3. okhttp-3.8.1.jar
  4. 奥基奥-1.13.0.jar
  5. SLF4J-API-1.7.25.jar
  6. 这也是similar issue on github

    这是堆栈跟踪I门和

    Info:   apartments was successfully deployed in 2,737 milliseconds.
    Severe:   SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    Severe:   SLF4J: Defaulting to no-operation (NOP) logger implementation
    Severe:   SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    Severe:   Exception in thread "RateLimitExecutorDelayThread"
    Severe:   java.lang.NoSuchMethodError: com.google.common.util.concurrent.RateLimiter.acquire()D
        at com.google.maps.internal.RateLimitExecutorService.run(RateLimitExecutorService.java:75)
        at java.lang.Thread.run(Thread.java:745)
    

1 个答案:

答案 0 :(得分:0)

在pom.xml中将Google API版本更改为0.2.0,如下所示 <dependency>     <groupId>com.google.maps</groupId>     <artifactId>google-maps-services</artifactId>     <version>0.2.0</version> ''

这将解决您的问题