带有Google Cloud Spring依赖项的本地开发

雷金

我目前正在实现一个Spring Boot应用程序,该应用程序对诸如的google云服务有很多依赖性PubSubspring boot自动配置为我创建了许多bean。例如一个MessagingGateway实现和一个PubSubTemplate

现在,我具有以下工件:

@Service
public class MyServiceImpl implements MyService {
    private final PubsubOutboundGateway messagingGateway;

    public MyServiceImpl(PubsubOutboundGateway messagingGateway) {
        this.messagingGateway = messagingGateway;
    }

    @Override
    public void sendToPubSub(String s) {
        messagingGateway.sendTest(s);
    }
}
@MessagingGateway
@Component
public interface PubsubOutboundGateway {
    @Gateway(requestChannel = "myChannel" )
    void sendTest(String test);
}
@Configuration
public class Channels {
    @Bean
    @ServiceActivator(inputChannel = "myChannel")
    public MessageHandler messageSender(PubSubTemplate pubsubTemplate) {
        return new PubSubMessageHandler(pubsubTemplate, "my-topic");
    }
}

当我关闭pubsub进行本地开发时,出现以下错误

Consider defining a bean of type 'com.google.cloud.spring.pubsub.core.PubSubTemplate' in your configuration.

但是我真正想要的是一个本地PubsubOutboundGateway,只打印消息。我可以通过增加实现这个@Profile("!local")PubsubOutboundGatewayChannels和实施PubsubOutboundGatewayLocalImpl但这似乎是一个hack。

如何在没有有效的GCP密钥等设置的情况下进行本地开发?还是只是阻碍开发,我应该使用活动密钥?

马丁·齐特勒

我建议使用Pub / Sub模拟器,以尽可能接近远程环境。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

部署具有本地依赖项的GCP Cloud功能

带有App Engine的本地或开发Google Cloud Firestore数据库

如何使用带有私有存储库中的依赖关系的Go运行Google Cloud Function?

您如何运行带有Google Cloud Storage客户端的Google App Engine开发服务器,所有内容都在本地模拟?

带有本地存储库的Spring Cloud Config Server配置

Google Cloud Functions包括Brew依赖项

带有Spring Cloud Load Balancer的Spring Cloud Kubernetes

带有Spring Cloud Gateway的Keycloak

带有Turbine配置的Spring Cloud领事

带有OpenTracing的Spring Cloud Sleuth

带有Spring Boot的Cloud Foundry

使用CloudTasks和Cloud Datastore进行本地开发以及使用带有Python3的GAE

带有Google Cloud Print的CUPS

带有Firebase的Google Cloud Platform

带有Javascript的Google Cloud Speech

带有ChildProcessError的Google Cloud Function错误

本地开发模式下的 Spring Cloud 配置

构建失败:构建带有本地包的Python Google Cloud Function时,构建错误详细信息不可用

Google Cloud Spanner开发

带有Spring Boot的微服务,没有Spring Cloud

带有非 Google 托管网站的 Google Cloud SQL

将docker用于Google Cloud数据流依赖项

使用TensorFlow作为依赖项部署Google Cloud Functions

如何打包Lambda / Google Cloud Functions而不包含所有不必要的依赖项

在 Cloud Functions 中为 NodeJS 指定私有依赖项

带有Spring-Cloud的Spring Boot:gradle构建失败

带有 spring-boot-starter-web 的 Spring Cloud Gateway

Cloud Bigtable是否有像Cloud Datastore这样的本地开发服务器?

带有Eureka的Spring Cloud-Eureka Web UI URL