我正在try 在我的Spring Boot项目中集成Spring-cloud-gcp-pub-substream-binder,以使用来自GCP pub子主题的事件,并在运行该项目时收到以下错误.
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.google.cloud.spring.stream.binder.pubsub.provisioning.PubSubChannelProvisioner.provisionConsumerDestination(PubSubChannelProvisioner.java:81)
The following method did not exist:
'boolean com.google.pubsub.v1.TopicName.isParsableFrom(java.lang.String)'
The calling method's class, com.google.cloud.spring.stream.binder.pubsub.provisioning.PubSubChannelProvisioner, was loaded from the following location:
jar:file:/Users/pranay.garg/.m2/repository/com/google/cloud/spring-cloud-gcp-pubsub-stream-binder/3.3.0/spring-cloud-gcp-pubsub-stream-binder-3.3.0.jar!/com/google/cloud/spring/stream/binder/pubsub/provisioning/PubSubChannelProvisioner.class
The called method's class, com.google.pubsub.v1.TopicName, is available from the following locations:
jar:file:/Users/pranay.garg/.m2/repository/com/google/api/grpc/proto-google-cloud-pubsub-v1/1.84.0/proto-google-cloud-pubsub-v1-1.84.0.jar!/com/google/pubsub/v1/TopicName.class
The called method's class hierarchy was loaded from the following locations:
com.google.pubsub.v1.TopicName: file:/Users/pranay.garg/.m2/repository/com/google/api/grpc/proto-google-cloud-pubsub-v1/1.84.0/proto-google-cloud-pubsub-v1-1.84.0.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes com.google.cloud.spring.stream.binder.pubsub.provisioning.PubSubChannelProvisioner and com.google.pubsub.v1.TopicName
我使用的是Spring Boot v2.6.1 和我的依赖关系管理
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>3.3.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>3.3.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2021.0.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
和我的相关依赖项
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-pubsub-stream-binder</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
</dependency
我认为这是一个版本兼容性问题,PubSubChannelProvisioner试图调用TopicName中的方法,但该方法不存在,但我无法找到解决此问题的方法. 如果您需要任何其他可能遗漏的信息,请告诉我. 感谢您的帮助,谢谢.