Spring Boot Cloud Data数据存储:使用Docker撰写的连接拒绝

发布于 2025-02-10 07:59:21 字数 1443 浏览 0 评论 0原文

我正在尝试准备使用数据存储的基础架构进行本地测试。当我检查LocalHost:由我的浏览器托管数据存储器的8081时,然后返回ok

我的docker-compoct

services:

  application:
    image: openjdk:17
    ports:
      - 9000:8080 # HTTP
    volumes:
      - ${BASE_PATH:-.}/build/libs/application.jar
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8080/health-check" ]
      interval: 10s
      timeout: 10s
      retries: 30
      start_period: 10s

  datastore:
    image: knarz/datastore-emulator
    ports:
      - 8081:8432
    environment:
      CONSISTENCY: 1 # If you omit this, the emulator will emulate eventual consistency.

my .yml文件

spring:
  cloud:
    gcp:
      project-id: test-project
      datastore:
        host: localhost:8081
        emulator:
          enabled: true
          port: 8081

我的方法获取数据:

    private DatastoreTemplate datastoreTemplate;

    public Entity getEntity(String id) {
        return datastoreTemplate.findById(id, Entity.class);
    }

异常非常通用:

Request processing failed; nested exception is com.google.cloud.datastore.DatastoreException: I/O error] with root cause","logger":"org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet]","thread_name":"http-nio-8080-exec-1","level":"ERROR","level_value":40000,"stack_trace":"java.net.ConnectException: Connection refused

I'm trying to prepare infrastructure for local testing with DataStore. When I check localhost:8081 by my browser, where DataStore is hosted, then it return ok.

My docker-compose

services:

  application:
    image: openjdk:17
    ports:
      - 9000:8080 # HTTP
    volumes:
      - ${BASE_PATH:-.}/build/libs/application.jar
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8080/health-check" ]
      interval: 10s
      timeout: 10s
      retries: 30
      start_period: 10s

  datastore:
    image: knarz/datastore-emulator
    ports:
      - 8081:8432
    environment:
      CONSISTENCY: 1 # If you omit this, the emulator will emulate eventual consistency.

My .yml file

spring:
  cloud:
    gcp:
      project-id: test-project
      datastore:
        host: localhost:8081
        emulator:
          enabled: true
          port: 8081

My method to get the data:

    private DatastoreTemplate datastoreTemplate;

    public Entity getEntity(String id) {
        return datastoreTemplate.findById(id, Entity.class);
    }

Exception is very generic:

Request processing failed; nested exception is com.google.cloud.datastore.DatastoreException: I/O error] with root cause","logger":"org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet]","thread_name":"http-nio-8080-exec-1","level":"ERROR","level_value":40000,"stack_trace":"java.net.ConnectException: Connection refused

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文