2017-08-11 96 views
0

我想獲取客戶從Google Places API輸入的地點名稱的經緯度。外行在第二行凍結。Google Maps Services Java客戶端凍結WebApp

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

這也是similar issue on github

這是堆棧跟蹤我門和

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) 
+0

你能解決嗎? – TimSchwalbe

+0

@TimSchwalbe是的,我終於能夠解決它。我使用舊版本,因爲谷歌API版本0.2.1有一個線程問題。 https://github.com/googlemaps/google-maps-services-java/issues/287#issuecomment-321938011 – qualebs

回答

0

更改谷歌API版本0.2.0到如下面的pom.xml <dependency> <groupId>com.google.maps</groupId> <artifactId>google-maps-services</artifactId> <version>0.2.0</version> ''

這會解決您的問題

相關問題