从独立Java应用程序访问数据存储区时,Pom.xml提供依赖错误

时间:2016-04-27 06:31:34

标签: google-cloud-datastore

我收到错误。即使更改了番石榴版本,我也无法解决此问题。我正在使用gcloud java从本地java应用程序连接到云数据存储区,我收到此依赖项错误。

java.lang.NoSuchMethodError: com.google.common.collect.Iterables.getFirst(Ljava/lang/Iterable;Ljava/lang/Object;)Ljava/lang/Object;

<dependencies>
    <dependency>                        <!-- REQUIRED -->
      <groupId>javax.servlet</groupId>  <!-- Java Servlet API -->
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>           <!-- Provided by the Jetty Servlet engine -->
    </dependency>

    <dependency>                        <!-- Java Server Pages -->
      <groupId>javax.servlet</groupId>
      <artifactId>jsp-api</artifactId>
      <version>2.0</version>
    </dependency>

    <dependency>                        <!-- JSP standard tag library -->
      <groupId>jstl</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>

    <dependency>                        <!-- Apache Taglibs -->
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
    </dependency>

    <dependency>                        <!-- Google Cloud Client Library for Java -->
      <groupId>com.google.cloud</groupId>
      <artifactId>gcloud-java</artifactId>
      <version>0.2.0</version>
    </dependency>

    <dependency>                        <!-- Google API client - for stuff that's not in gcloud-->
      <groupId>com.google.api-client</groupId>
      <artifactId>google-api-client</artifactId>
      <version>1.21.0</version>
    </dependency>

    <dependency>                        <!-- Google+ API Client Library for Java -->
      <groupId>com.google.apis</groupId>
      <artifactId>google-api-services-plus</artifactId>
      <version>v1-rev339-1.21.0</version>
    </dependency>

    <dependency>                        <!-- https://github.com/FasterXML/jackson-databind -->
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.7.0</version>
    </dependency>

    <dependency>                        <!-- Google Core Libraries for Java -->
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>  <!-- https://github.com/google/guava/wiki -->
        <version>10.0.1</version>
    </dependency>

    <dependency>                        <!-- http://www.joda.org/joda-time/ -->
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
      <version>2.9.2</version>
    </dependency>

    <dependency>                        <!-- http://dev.mysql.com/doc/connector-j/en/ -->
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.38</version>
    </dependency>

    <dependency>                        <!-- Apache Database Connection Pool API -->
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-dbcp2</artifactId>
      <version>2.1.1</version>
    </dependency>

  </dependencies>My pom.xml has the following dependencies:

2 个答案:

答案 0 :(得分:0)

请检查您的容器模块版本。

例如,GlassFish Server具有旧版本的guava lib。 如果可能(和实际)检查您的“GlassFish_Server / glassfish / modules /”目录。

答案 1 :(得分:-1)

可能为时已晚,但这是我的答案:NoSuchMethodError的根本原因是你用另一个版本而不是执行类编译了你的类。请检查主要家属的依赖关系树。我的观点是针对com.google.api-client,但我无法保证......

奖励:此article

中的NoSuchMethodError和NoSuchMethodException之间存在差异