Spring Boot Cloud Data数据存储:使用Docker撰写的连接拒绝
我正在尝试准备使用数据存储的基础架构进行本地测试。当我检查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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论