我在这个问题上花了很长时间,所以想给小费。 setBatchPath
的问题在于它是在google-api-client 1.23.0及更高版本中引入的。我在gradle.build文件中包含了最新版本的google-api-client,但是该项目的其他地方存在替代,这迫使google-api-client 1.22.0的使用被破坏了。
如果遇到此问题,请尝试以下操作:
- 例如,检查构建目录
build/dependency
中的jar版本。
- 运行
gradle dependencyInsight --dependency com.google.api-client
来查看gradle正在进行的操作
对我来说,解决方法是在库项目和使用该库的服务中的build.gradle中添加以下内容。
dependencyManagement {
dependencies{
dependency 'com.google.apis:google-api-services-sheets:v4-rev607-1.25.0'
dependency 'com.google.api-client:google-api-client:1.25.0'
}
}
,
新版jars不包含您要调用的方法。阅读这些软件包的API,以了解如何与以前的版本区别使用它们。
,
在您的项目中使用这些依赖项:
<dependencies>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-sheets</artifactId>
<version>v4-rev1-1.21.0</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId>
<version>1.30.4</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-java6</artifactId>
<version>1.30.4</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>1.30.4</version>
</dependency>
</dependencies>
您可以通过Google HERE查看所有当前的官方依赖项版本。
,
使用以下命令检查项目的依赖树。
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:tree -Dverbose=truemvn org.apache.maven.plugins:maven-dependency-plugin:2.10:tree -Dverbose=true
检查 google-api-client jar 的不同版本,并且只包含 1.23.0 版本并排除其他版本,如下所示。它应该可以工作。
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-dataflow</artifactId>
<version>v1b3-rev207-1.20.0</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
</exclusion>
</exclusions>
</dependency>
,
使用以下命令检查项目的依赖树
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:tree -Dverbose=truemvn org.apache.maven.plugins:maven-dependency-plugin:2.10:tree -Dverbose=true
并包括 1.23.0 版本的 google-api-client 并排除其他版本,如下所示。
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-dataflow</artifactId>
<version>v1b3-rev207-1.20.0</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
</exclusion>
</exclusions>
</dependency>
本文链接:https://www.f2er.com/3090017.html