对于类型StorageOptions,未定义方法getService()

时间:2020-01-20 18:15:09

标签: java firebase google-cloud-storage storage

我只是在试用FirebaseAdmin SDK,并且在Eclipse Java中使用以下代码时,

    Storage storage = StorageOptions.getDefaultInstance().getService();

我收到一条错误消息:“ com.google.cloud.ServiceOptions类型无法解析。它是从所需的.class文件中间接引用的。未为类型StorageOptions定义getService()方法。” 我不确定在这里是否缺少某些依赖项,但这是我到目前为止使用的依赖项:

<dependency>
    <groupId>com.google.firebase</groupId>
    <artifactId>firebase-admin</artifactId>
    <version>6.12.0</version>
</dependency>


<dependency>
    <groupId>com.google.auth</groupId>
    <artifactId>google-auth-library-oauth2-http</artifactId>
    <version>0.19.0</version>
</dependency>

<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-storage</artifactId>
    <version>1.103.0</version>
</dependency>


<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-core</artifactId>
    <version>1.92.2</version>
</dependency>


<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-core-http</artifactId>
    <version>1.92.2</version>
</dependency>



<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
    <version>4.1.4.Final</version>
</dependency>

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.12</version>
</dependency>

不知道怎么了....:/任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:1)

嗯,事实证明,我需要添加“ requires google.cloud.core;”。在模块文件下删除该错误。