我刚刚从 spring 2 -> 3 升级了我的应用程序,从那时起我收到了与 Pub/Sub 和凭证相关的错误。我尝试在映像构建过程中添加服务帐户,但这也不起作用。
#pubsub
spring.cloud.gcp.project-id=qzf-product-play-13cf
spring.cloud.gcp.pubsub.emulator-host=localhost:8681
spring.cloud.gcp.credentials.location=classpath:test.json
spring.cloud.gcp.project-id=local-project
然后我看看它是否在 main 方法中拾取文件,它是
public static void main(final String[] args) {
String credentialsLocation = "classpath:test.json";
System.out.println("Trying to load credentials from: " + credentialsLocation);
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-pubsub</artifactId>
<version>3.5.4</version>
</dependency>
错误
{"timestamp":"2024-05-14T06:21:54.56208905Z","@version":"1","msg":"Could not create publisher.","logger_name":"product.tt.serviceconfig.pubsub.AbstractEntityPublisher","thread_name":"main","severity":"ERROR","level_value":40000,"stack_trace":"java.io.IOException: Your default credentials were not found. To set up Application Default Credentials for your environment, see https://cloud.google.com/docs/authentication/external/set-up-adc.\n\tat com.google.auth.oauth2.DefaultCredentialsProvider.getDefaultCredentials(DefaultCredentialsProvider.java:127)\n\tat com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:129)\n\tat com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:101)\n\tat com.google.api.gax.core.GoogleCredentialsProvider.getCredentials(GoogleCredentialsProvider.java:70)\n\tat com.google.api.gax.rpc.ClientContext.create(ClientContext.java:168)\n\tat com.google.cloud.pubsub.v1.stub.GrpcPublisherStub.create(GrpcPublisherStub.java:203)\n\tat com.google.cloud.pubsub.v1.Publisher.<init>(Publisher.java:201)\n\tat com.google.cloud.pubsub.v1.Publisher.<init>(Publisher.java:91)\n\tat com.google.cloud.pubsub.v1.Publisher$Builder.build(Publisher.java:881)
我不知道还能尝试什么。我已经这样做了四天了,但无法解决这个错误。
任何建议将不胜感激。