Google Storage客户端库(appengine-gcs-client)具有不可用的依赖项(google-http-client-parent:pom:1.24.1)

时间:2018-08-01 13:26:15

标签: java maven google-app-engine google-cloud-storage

我通过以下操作将appengine-gcs-client添加到我的Google AppEngine Standard项目中:

    *<dependency>
        <groupId>com.google.appengine.tools</groupId>
        <artifactId>appengine-gcs-client</artifactId>
        <version>0.7</version>
    </dependency>*

(遵循此页面上的指示:https://cloud.google.com/appengine/docs/standard/java/googlecloudstorageclient/setting-up-cloud-storage

编译项目会引发以下错误(几天前没有问题):

[错误]无法在项目myproject2上执行目标:无法解析项目com.myproject2:myproject2:war:1.0-SNAPSHOT的依赖项:无法在com.google.appengine.tools:appengine-上收集依赖项gcs-client:jar:0.7-> com.google.api-client:google-api-client-appengine:jar:1.24.1-> com.google.oauth-client:google-oauth-client-appengine:jar: 1.24.1-> com.google.http-client:google-http-client-appengine:jar:1.24.1:无法读取com.google.http-client:google-http-client-appengine:jar的工件描述符:1.24.1:在本地https://repo.maven.apache.org/maven2中找不到com.google.http-client:google-http-client-parent:pom:1.24.1的内容已缓存在本地存储库中,直到更新后才会重新尝试解析中心间隔已过去或强制进行了更新-> [帮助1]

似乎Google刚刚在依赖树中创建了一些错误。

有什么办法可以解决它,甚至只是临时解决方法?


使用完整的pom更新我的问题,该错误会重现错误:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <packaging>war</packaging>
    <version>0.1.0-SNAPSHOT</version>

    <groupId>com.myproject2</groupId>
    <artifactId>myproject2</artifactId>

    <properties>
        <appengine.maven.plugin.version>1.3.1</appengine.maven.plugin.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
    </properties>

    <prerequisites>
        <maven>3.3.9</maven>
    </prerequisites>

    <dependencies>
        <!-- Compile/runtime dependencies -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>1.9.59</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- For cloud storage https://cloud.google.com/appengine/docs/standard/java/googlecloudstorageclient/setting-up-cloud-storage -->
        <dependency>
            <groupId>com.google.appengine.tools</groupId>
            <artifactId>appengine-gcs-client</artifactId>
            <version>0.7</version>
        </dependency>

        <!-- Test Dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.endpoints</groupId>
            <artifactId>endpoints-framework</artifactId>
            <version>2.1.1</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.objectify</groupId>
            <artifactId>objectify</artifactId>
            <version>6.0</version>
        </dependency>
    </dependencies>

    <build>
        <!-- for hot reload of the web application -->
        <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>display-dependency-updates</goal>
                            <goal>display-plugin-updates</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.maven.plugin.version}</version>
            </plugin>
        </plugins>
    </build>
</project>

5 个答案:

答案 0 :(得分:4)

似乎Google进行了一些重命名(它们删除了artifactIds的“ -appengine”部分),这在1.24.1版本中不起作用。尝试将gcs依赖项替换为以下内容:

<dependency>
    <groupId>com.google.appengine.tools</groupId>
    <artifactId>appengine-gcs-client</artifactId>
    <version>0.7</version>
  <exclusions>
    <exclusion>
      <groupId>com.google.http-client</groupId>
      <artifactId>*</artifactId>
    </exclusion> 
  </exclusions>
</dependency>
<dependency>
  <groupId>com.google.http-client</groupId>
  <artifactId>google-http-client-appengine</artifactId>
  <version>1.23.0</version>
</dependency>

它将排除所有与1.24.1版本无关的依赖项,而是使用以前的1.23.0。您可能最终需要强制Maven使用“ -U”标志来更新远程依赖关系,例如,

mvn -U package

答案 1 :(得分:3)

我面临着appengine-mapreduce依赖关系的错误。 通过排除引发错误的依赖项来解决此问题。

原始地图可减少依赖性

<dependency>
            <groupId>com.google.appengine.tools</groupId>
            <artifactId>appengine-mapreduce</artifactId>
            <version>0.9</version>
</dependency>

显示的错误

  

无法解决项目的依赖关系   PerpuleSmartShoppee:PerpuleSmartShoppee:war:0.0.1-SNAPSHOT:失败   在以下位置收集依赖项   com.google.appengine.tools:appengine-mapreduce:jar:0.9->   com.google.appengine.tools:appengine-gcs-client:jar:0.4.3->   com.google.api-client:google-api-client-appengine:jar:1.24.1->   com.google.oauth-client:google-oauth-client-appengine:jar:1.24.1->   com.google.http-client:google-http-client-appengine:jar:1.24.1:失败   读取工件描述符   com.google.http-client:google-http-client-appengine:jar:1.24.1:   找不到   com.google.http-client:google-http-client-parent:pom:1.24.1中   https://repo.maven.apache.org/maven2已缓存在本地   存储库,直到更新后才会重新尝试解析   中心间隔已过去或强制更新->

将其更改为以下内容以使构建正常工作

<dependency>
            <groupId>com.google.api-client</groupId>
            <artifactId>google-api-client</artifactId>
            <version>1.22.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>guava-jdk5</artifactId>
                    <groupId>com.google.guava</groupId>
                </exclusion>
            </exclusions>
        </dependency>
    <dependency>
                <groupId>com.google.api-client</groupId>
                <artifactId>google-api-client-appengine</artifactId>
                <version>1.22.0</version>
                <exclusions>
                    <exclusion>
                        <artifactId>guava</artifactId>
                        <groupId>com.google.guava</groupId>
                    </exclusion>
                </exclusions>   
            </dependency>
            <dependency>
                <groupId>com.google.appengine.tools</groupId>
                <artifactId>appengine-gcs-client</artifactId>
                <version>0.3</version>
                <exclusions>
                    <exclusion>
                        <artifactId>guava</artifactId>
                        <groupId>com.google.guava</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
              <dependency>
                <groupId>com.google.appengine.tools</groupId>
                <artifactId>appengine-mapreduce</artifactId>
                <version>0.9</version>
                <exclusions>
                    <exclusion>
                        <artifactId>guava</artifactId>
                        <groupId>com.google.guava</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>appengine-gcs-client</artifactId>
                        <groupId>com.google.appengine.tools</groupId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.google.api-client</groupId>
                        <artifactId>google-api-client</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.google.api-client</groupId>
                        <artifactId>google-api-client-appengine</artifactId>
                    </exclusion>

                </exclusions>
            </dependency> 

答案 2 :(得分:3)

尝试再次运行它。昨天Google更新了Maven版本时,并未将完整更新推送到库中。从那以后,他们推了丢失的那一块,现在它应该可以正常工作,无需任何修改。

答案 3 :(得分:2)

昨天,Google显然未能为其com.google.http-client库的父级部署1.24.0版本。

enter image description here

他们还采用了不受欢迎的做法,即在appengine-gcs-client pom中声明其http客户端依赖项的范围:

<dependency>
  <groupId>com.google.http-client</groupId>
  <artifactId>google-http-client</artifactId>
  <version>[1.19.0,2.0)</version>
</dependency>
<dependency>
  <groupId>com.google.http-client</groupId>
  <artifactId>google-http-client-jackson2</artifactId>
  <version>[1.19,2.0)</version>
</dependency>

因此,当他们昨天部署新版本1.24.0时,传递依赖项会自动升级,但是该版本是无效部署,导致失败。

这为我解决了问题

       <dependency>
            <groupId>com.google.appengine.tools</groupId>
            <artifactId>appengine-gcs-client</artifactId>
            <version>0.6</version>
            <exclusions>
                <exclusion>
                    <groupId>com.google.http-client</groupId>
                    <artifactId>google-http-client-jackson2</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.http-client</groupId>
                    <artifactId>google-http-client</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.http-client</groupId>
            <artifactId>google-http-client-jackson2</artifactId>
            <version>1.23.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.http-client</groupId>
            <artifactId>google-http-client</artifactId>
            <version>1.23.0</version>
        </dependency>

答案 4 :(得分:0)

尝试MavenUpdate-

强制更新 勾选---复选框ReleasesForceUpdate快照/发布