【发布时间】:2019-07-26 02:27:58
【问题描述】:
我正在使用 Spring Boot Starter spring-cloud-gcp-starter-pubsub 和 PubSubTemplate。它与实际的 GCP 完美配合,但现在我想将它用于本地 Google PubSub 模拟器的测试。如何提供我的自定义 url、端口和无凭据?
或者我必须像this example那样恢复使用普通的google sdk
编辑:
我的应用中只有一个 bean:
@Service
class TestLocalPubsub(pubSubTemplate: PubSubTemplate)
和
application.properties:
spring.cloud.gcp.pubsub.emulator-host=localhost:8085
当我运行应用程序时,我得到了:
原因:java.io.IOException:应用程序默认凭据不可用。如果在 Google Compute Engine 中运行,它们就可用。否则,必须定义环境变量 GOOGLE_APPLICATION_CREDENTIALS 指向定义凭据的文件。有关更多信息,请参阅https://developers.google.com/accounts/docs/application-default-credentials。 在 com.google.auth.oauth2.DefaultCredentialsProvider.getDefaultCredentials(DefaultCredentialsProvider.java:132) ~[google-auth-library-oauth2-http-0.12.0.jar:na] ...
但当然链接说的是 gcloud sdk,而不是 pubsubtemplate
【问题讨论】:
-
你能发布完整的堆栈跟踪吗?我
-
检查this的答案,可能会有帮助。
标签: java spring-boot spring-cloud google-cloud-pubsub spring-cloud-gcp