Dockerized Spring boot应用程序连接到mongoDB docker镜像不起作用

发布于 2025-01-11 08:15:26 字数 9407 浏览 0 评论 0原文

我试图找出为什么 dockerized Spring boot 应用程序和 mongoDB 之间的通信不起作用。首先要做的事情是: 整个微服务在本地完美运行。 我使用配置文件名称 docker 创建一个 application.properties: application-docker.properties

server.port=8091
spring.application.name=customer
# ============================================================================================================
# EUREKA
# It's not possible to use localhost in the docker container. Instate use the container name.
# In this case "eureka-server". See the file docker-compose.yml to check the container name.
eureka.client.service-url.defaultZone=http://eureka-server:8761/eureka
eureka.client.fetch-registry=true
eureka.client.register-with-eureka=true
# ============================================================================================================
# ZIPKIN
# It's not possible to use localhost in the docker container. Instate use the container name.
# In this case "zipkin". See the file docker-compose.yml to check the container name.
spring.zipkin.base-url=http://zipkin:9411
# ============================================================================================================
# RABBIT_MQ
# It's not possible to use localhost in the docker container. Instate use the container name.
# In this case "rabbitmq". See the file docker-compose.yml to check the container name.
spring.rabbitmq.addresses=rabbitmq:5672
rabbitmq.exchanges.internal=internal.exchange
rabbitmq.queue.notification=notification.queue
rabbitmq.routing-keys.internal-notification=internal.notification.routing-key
# ============================================================================================================
# MONGO-DB
spring.data.mongodb.authentication-database=admin
spring.data.mongodb.username=rootuser
spring.data.mongodb.password=rootpass
#spring.data.mongodb.database=data
#spring.data.mongodb.host=spring
#spring.data.mongodb.port=27017
spring.data.mongodb.uri=mongodb://mongodb:27017/data

,然后启动 docker 后的 docker-compose.yml

services:
  mongodb:
    container_name: mongodb
    image: mongo:latest
    hostname: mongo
    restart: unless-stopped
    ports:
      - 27017:27017
    volumes:
      - data:/data
    environment:
      - MONGO_INITDB_ROOT_USERNAME=rootuser
      - MONGO_INITDB_ROOT_PASSWORD=rootpass
    networks:
      - spring

  mongo-express:
    container_name: mongo-express
    image: mongo-express
    restart: always
    ports:
      - 8095:8081
    environment:
      - ME_CONFIG_MONGODB_ADMINUSERNAME=rootuser
      - ME_CONFIG_MONGODB_ADMINPASSWORD=rootpass
      - ME_CONFIG_MONGODB_SERVER=mongodb
    networks:
      - spring
    
  zipkin:
    image: openzipkin/zipkin
    container_name: zipkin
    ports:
      - 9411:9411
    networks:
      - spring

  rabbitmq:
    image: rabbitmq:3.9.11-management-alpine
    container_name: rabbitmq
    ports:
      - 5672:5672
      - 15672:15672
    networks:
      - spring

  eureka-server:
    image: koulombus/eureka-server:latest
    container_name: eureka-server
    ports:
      - 8761:8761
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin

  api-gateway:
    image: koulombus/api-gateway:latest
    container_name: api-gateway
    ports:
      - 8090:8090
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server

  customer:
    image: koulombus/customer:latest
    container_name: customer
    ports:
      - 8091:8091
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server
      - rabbitmq
      - mongodb

  fraud:
    image: koulombus/fraud:latest
    container_name: fraud
    ports:
      - 8092:8092
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server
      - rabbitmq

  notification:
    image: koulombus/notification:latest
    container_name: notification
    ports:
      - 8093:8093
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server
      - rabbitmq

volumes:
  postgres:
  pgadmin:
  data: {}

networks:
  postgres:
    driver: bridge
  spring:
    driver: bridge

...

mvn clean package -P "build-docker-image"
docker compose up -d

事实

尤里卡服务器: 输入图片此处描述

Ziplin: 输入图片此处描述

RabbitMQ: 输入图片此处描述

Mongo-express: 输入图片此处描述

问题 当我现在检查客户登录 docker 时,我看到以下内容:

 ,-----. ,--. ,--.  ,---.   ,--------.  ,-----.  ,--.   ,--. ,------. ,------.

'  .--./ |  | |  | '   .-'  '--.  .--' '  .-.  ' |   `.'   | |  .---' |  .--. '

|  |     |  | |  | `.  `-.     |  |    |  | |  | |  |'.'|  | |  `--,  |  '--'.'

'  '--'\ '  '-'  ' .-'    |    |  |    '  '-'  ' |  |   |  | |  `---. |  |\  \

 `-----'  `-----'  `-----'     `--'     `-----'  `--'   `--' `------' `--' '--'


Application Name: 

Application Version: 

:: Spring Boot ::                 (v2.6.3)



2022-03-03 08:58:55.187  INFO [customer,,] 1 --- [           main] c.k.customer.CustomerApplication         : Starting CustomerApplication using Java 17.0.1 on cf6b5b41507d with PID 1 (/app/classes started by root in /)

2022-03-03 08:58:55.241  INFO [customer,,] 1 --- [           main] c.k.customer.CustomerApplication         : The following profiles are active: docker

2022-03-03 08:59:01.557  INFO [customer,,] 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.

2022-03-03 08:59:02.239  INFO [customer,,] 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 667 ms. Found 1 MongoDB repository interfaces.

2022-03-03 08:59:04.589  INFO [customer,,] 1 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=9e7fc4f4-3641-3895-b9a0-4754b711f194

2022-03-03 08:59:08.906  INFO [customer,,] 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8091 (http)

2022-03-03 08:59:08.952  INFO [customer,,] 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]

2022-03-03 08:59:08.953  INFO [customer,,] 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.56]

2022-03-03 08:59:09.454  INFO [customer,,] 1 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext

2022-03-03 08:59:09.454  INFO [customer,,] 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 13490 ms

2022-03-03 08:59:12.729  INFO [customer,,] 1 --- [           main] org.mongodb.driver.cluster               : Cluster created with settings {hosts=[mongodb:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms'}

2022-03-03 08:59:13.071  INFO [customer,,] 1 --- [}-mongodb:27017] org.mongodb.driver.cluster               : Exception in monitor thread while connecting to server mongodb:27017


com.mongodb.MongoSocketException: mongodb

at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:211) ~[mongodb-driver-core-4.4.1.jar:na]

at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:75) ~[mongodb-driver-core-4.4.1.jar:na]

at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65) ~[mongodb-driver-core-4.4.1.jar:na]

at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:180) ~[mongodb-driver-core-4.4.1.jar:na]

at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.lookupServerDescription(DefaultServerMonitor.java:188) ~[mongodb-driver-core-4.4.1.jar:na]

at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:152) ~[mongodb-driver-core-4.4.1.jar:na]

at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]

Caused by: java.net.UnknownHostException: mongodb

at java.base/java.net.InetAddress$CachedAddresses.get(InetAddress.java:801) ~[na:na]

at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:887) ~[na:na]

at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1509) ~[na:na]

at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1367) ~[na:na]

at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1301) ~[na:na]

at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:203) ~[mongodb-driver-core-4.4.1.jar:na]

... 6 common frames omitted

我在某个地方犯了一个错误。我将非常感谢您的提示。

I try to figure out why the communication between dockerized Spring boot app and mongoDB is not working. First things first:
The whole microservice is running localy perfectly.
I create an application.properties with the profile name docker:
application-docker.properties

server.port=8091
spring.application.name=customer
# ============================================================================================================
# EUREKA
# It's not possible to use localhost in the docker container. Instate use the container name.
# In this case "eureka-server". See the file docker-compose.yml to check the container name.
eureka.client.service-url.defaultZone=http://eureka-server:8761/eureka
eureka.client.fetch-registry=true
eureka.client.register-with-eureka=true
# ============================================================================================================
# ZIPKIN
# It's not possible to use localhost in the docker container. Instate use the container name.
# In this case "zipkin". See the file docker-compose.yml to check the container name.
spring.zipkin.base-url=http://zipkin:9411
# ============================================================================================================
# RABBIT_MQ
# It's not possible to use localhost in the docker container. Instate use the container name.
# In this case "rabbitmq". See the file docker-compose.yml to check the container name.
spring.rabbitmq.addresses=rabbitmq:5672
rabbitmq.exchanges.internal=internal.exchange
rabbitmq.queue.notification=notification.queue
rabbitmq.routing-keys.internal-notification=internal.notification.routing-key
# ============================================================================================================
# MONGO-DB
spring.data.mongodb.authentication-database=admin
spring.data.mongodb.username=rootuser
spring.data.mongodb.password=rootpass
#spring.data.mongodb.database=data
#spring.data.mongodb.host=spring
#spring.data.mongodb.port=27017
spring.data.mongodb.uri=mongodb://mongodb:27017/data

and then the docker-compose.yml

services:
  mongodb:
    container_name: mongodb
    image: mongo:latest
    hostname: mongo
    restart: unless-stopped
    ports:
      - 27017:27017
    volumes:
      - data:/data
    environment:
      - MONGO_INITDB_ROOT_USERNAME=rootuser
      - MONGO_INITDB_ROOT_PASSWORD=rootpass
    networks:
      - spring

  mongo-express:
    container_name: mongo-express
    image: mongo-express
    restart: always
    ports:
      - 8095:8081
    environment:
      - ME_CONFIG_MONGODB_ADMINUSERNAME=rootuser
      - ME_CONFIG_MONGODB_ADMINPASSWORD=rootpass
      - ME_CONFIG_MONGODB_SERVER=mongodb
    networks:
      - spring
    
  zipkin:
    image: openzipkin/zipkin
    container_name: zipkin
    ports:
      - 9411:9411
    networks:
      - spring

  rabbitmq:
    image: rabbitmq:3.9.11-management-alpine
    container_name: rabbitmq
    ports:
      - 5672:5672
      - 15672:15672
    networks:
      - spring

  eureka-server:
    image: koulombus/eureka-server:latest
    container_name: eureka-server
    ports:
      - 8761:8761
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin

  api-gateway:
    image: koulombus/api-gateway:latest
    container_name: api-gateway
    ports:
      - 8090:8090
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server

  customer:
    image: koulombus/customer:latest
    container_name: customer
    ports:
      - 8091:8091
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server
      - rabbitmq
      - mongodb

  fraud:
    image: koulombus/fraud:latest
    container_name: fraud
    ports:
      - 8092:8092
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server
      - rabbitmq

  notification:
    image: koulombus/notification:latest
    container_name: notification
    ports:
      - 8093:8093
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server
      - rabbitmq

volumes:
  postgres:
  pgadmin:
  data: {}

networks:
  postgres:
    driver: bridge
  spring:
    driver: bridge

after starting docker...

mvn clean package -P "build-docker-image"
docker compose up -d

Facts

Eureka-Server:
enter image description here

Ziplin:
enter image description here

RabbitMQ:
enter image description here

Mongo-express:
enter image description here

Problem
When I check now the customer log in docker i facet following:

 ,-----. ,--. ,--.  ,---.   ,--------.  ,-----.  ,--.   ,--. ,------. ,------.

'  .--./ |  | |  | '   .-'  '--.  .--' '  .-.  ' |   `.'   | |  .---' |  .--. '

|  |     |  | |  | `.  `-.     |  |    |  | |  | |  |'.'|  | |  `--,  |  '--'.'

'  '--'\ '  '-'  ' .-'    |    |  |    '  '-'  ' |  |   |  | |  `---. |  |\  \

 `-----'  `-----'  `-----'     `--'     `-----'  `--'   `--' `------' `--' '--'


Application Name: 

Application Version: 

:: Spring Boot ::                 (v2.6.3)



2022-03-03 08:58:55.187  INFO [customer,,] 1 --- [           main] c.k.customer.CustomerApplication         : Starting CustomerApplication using Java 17.0.1 on cf6b5b41507d with PID 1 (/app/classes started by root in /)

2022-03-03 08:58:55.241  INFO [customer,,] 1 --- [           main] c.k.customer.CustomerApplication         : The following profiles are active: docker

2022-03-03 08:59:01.557  INFO [customer,,] 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data MongoDB repositories in DEFAULT mode.

2022-03-03 08:59:02.239  INFO [customer,,] 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 667 ms. Found 1 MongoDB repository interfaces.

2022-03-03 08:59:04.589  INFO [customer,,] 1 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=9e7fc4f4-3641-3895-b9a0-4754b711f194

2022-03-03 08:59:08.906  INFO [customer,,] 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8091 (http)

2022-03-03 08:59:08.952  INFO [customer,,] 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]

2022-03-03 08:59:08.953  INFO [customer,,] 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.56]

2022-03-03 08:59:09.454  INFO [customer,,] 1 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext

2022-03-03 08:59:09.454  INFO [customer,,] 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 13490 ms

2022-03-03 08:59:12.729  INFO [customer,,] 1 --- [           main] org.mongodb.driver.cluster               : Cluster created with settings {hosts=[mongodb:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms'}

2022-03-03 08:59:13.071  INFO [customer,,] 1 --- [}-mongodb:27017] org.mongodb.driver.cluster               : Exception in monitor thread while connecting to server mongodb:27017


com.mongodb.MongoSocketException: mongodb

at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:211) ~[mongodb-driver-core-4.4.1.jar:na]

at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:75) ~[mongodb-driver-core-4.4.1.jar:na]

at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65) ~[mongodb-driver-core-4.4.1.jar:na]

at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:180) ~[mongodb-driver-core-4.4.1.jar:na]

at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.lookupServerDescription(DefaultServerMonitor.java:188) ~[mongodb-driver-core-4.4.1.jar:na]

at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:152) ~[mongodb-driver-core-4.4.1.jar:na]

at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]

Caused by: java.net.UnknownHostException: mongodb

at java.base/java.net.InetAddress$CachedAddresses.get(InetAddress.java:801) ~[na:na]

at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:887) ~[na:na]

at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1509) ~[na:na]

at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1367) ~[na:na]

at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1301) ~[na:na]

at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:203) ~[mongodb-driver-core-4.4.1.jar:na]

... 6 common frames omitted

Somewhere I make a mistake. I would be very grateful for a hint.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

安稳善良 2025-01-18 08:15:26

好的,适合我的解决方案:

application-docker.properties

spring.data.mongodb.authentication-database=admin
spring.data.mongodb.username=rootuser
spring.data.mongodb.password=rootpass
spring.data.mongodb.host=mongodb
spring.data.mongodb.port=27017
spring.data.mongodb.database=data

docker-compose.yml

services:
  mongodb:
    container_name: mongodb
    image: mongo:latest
    hostname: mongo
    restart: unless-stopped
    ports:
      - 27017:27017
    volumes:
      - data:/data
    environment:
      - MONGO_INITDB_ROOT_USERNAME=rootuser
      - MONGO_INITDB_ROOT_PASSWORD=rootpass
    networks:
      - spring

  mongo-express:
    container_name: mongo-express
    image: mongo-express
    restart: always
    ports:
      - 8095:8081
    environment:
      - ME_CONFIG_MONGODB_ADMINUSERNAME=rootuser
      - ME_CONFIG_MONGODB_ADMINPASSWORD=rootpass
      - ME_CONFIG_MONGODB_SERVER=mongodb
    depends_on:
      - mongodb
    networks:
      - spring

  zipkin:
    image: openzipkin/zipkin
    container_name: zipkin
    ports:
      - 9411:9411
    networks:
      - spring

  rabbitmq:
    image: rabbitmq:3.9.11-management-alpine
    container_name: rabbitmq
    ports:
      - 5672:5672
      - 15672:15672
    networks:
      - spring

  eureka-server:
    image: koulombus/eureka-server:latest
    container_name: eureka-server
    ports:
      - 8761:8761
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin

  api-gateway:
    image: koulombus/api-gateway:latest
    container_name: api-gateway
    ports:
      - 8090:8090
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server

  customer:
    image: koulombus/customer:latest
    container_name: customer
    ports:
      - 8091:8091
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server
      - rabbitmq
      - mongodb
      - fraud

  fraud:
    image: koulombus/fraud:latest
    container_name: fraud
    ports:
      - 8092:8092
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server
      - rabbitmq
      - mongodb

  notification:
    image: koulombus/notification:latest
    container_name: notification
    ports:
      - 8093:8093
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server
      - rabbitmq
      - mongodb

volumes:
  postgres:
  pgadmin:
  data: {}

networks:
  postgres:
    driver: bridge
  spring:
    driver: bridge

OK, working solution for me:

application-docker.properties

spring.data.mongodb.authentication-database=admin
spring.data.mongodb.username=rootuser
spring.data.mongodb.password=rootpass
spring.data.mongodb.host=mongodb
spring.data.mongodb.port=27017
spring.data.mongodb.database=data

docker-compose.yml

services:
  mongodb:
    container_name: mongodb
    image: mongo:latest
    hostname: mongo
    restart: unless-stopped
    ports:
      - 27017:27017
    volumes:
      - data:/data
    environment:
      - MONGO_INITDB_ROOT_USERNAME=rootuser
      - MONGO_INITDB_ROOT_PASSWORD=rootpass
    networks:
      - spring

  mongo-express:
    container_name: mongo-express
    image: mongo-express
    restart: always
    ports:
      - 8095:8081
    environment:
      - ME_CONFIG_MONGODB_ADMINUSERNAME=rootuser
      - ME_CONFIG_MONGODB_ADMINPASSWORD=rootpass
      - ME_CONFIG_MONGODB_SERVER=mongodb
    depends_on:
      - mongodb
    networks:
      - spring

  zipkin:
    image: openzipkin/zipkin
    container_name: zipkin
    ports:
      - 9411:9411
    networks:
      - spring

  rabbitmq:
    image: rabbitmq:3.9.11-management-alpine
    container_name: rabbitmq
    ports:
      - 5672:5672
      - 15672:15672
    networks:
      - spring

  eureka-server:
    image: koulombus/eureka-server:latest
    container_name: eureka-server
    ports:
      - 8761:8761
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin

  api-gateway:
    image: koulombus/api-gateway:latest
    container_name: api-gateway
    ports:
      - 8090:8090
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server

  customer:
    image: koulombus/customer:latest
    container_name: customer
    ports:
      - 8091:8091
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server
      - rabbitmq
      - mongodb
      - fraud

  fraud:
    image: koulombus/fraud:latest
    container_name: fraud
    ports:
      - 8092:8092
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server
      - rabbitmq
      - mongodb

  notification:
    image: koulombus/notification:latest
    container_name: notification
    ports:
      - 8093:8093
    environment:
      - SPRING_PROFILES_ACTIVE=docker
    networks:
      - spring
    depends_on:
      - zipkin
      - eureka-server
      - rabbitmq
      - mongodb

volumes:
  postgres:
  pgadmin:
  data: {}

networks:
  postgres:
    driver: bridge
  spring:
    driver: bridge
尬尬 2025-01-18 08:15:26

您的配置文件中的 spring.data.mongodb.uri 中缺少“s”。

You're missing an 's' in spring.data.mongodb.uri in your config file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文