Docker RabbitMQ和Spring不创建密码

问题描述 投票:0回答:1

我正在尝试使用rabbitmq部署spring应用程序,但出现连接拒绝错误。我使用默认的user:password(guest:guest),但是在创建用户时无需密码即可]

Created new connection: rabbitConnectionFactory#60d8c0dc:5/SimpleConnection@358e0edb [delegate=amqp://[email protected]:5672/, localPort= 53472]

Docker-compose.yml

version: '3'

services:
  rabbitmq:
    image: rabbitmq:management
    environment:
      RABBITMQ_DEFAULT_USER: "guest"
      RABBITMQ_DEFAULT_PASS: "guest"
    ports:
      - "5672:5672" #JMS Port
      - "15672:15672" #Management Port - default user:pass = guest:guest
    networks:
      - rabbit_mq

  db:
    image: mysql:5.7.22
    environment:
      MYSQL_ROOT_PASSWORD: "root"
      MYSQL_DATABASE: "hospital"
      MYSQL_PASSWORD: "root"
    ports:
      - "3306:3306"
    networks:
      - mysql_bridge
    restart: always

  springboot-docker-compose-app-container:
    image: app-image
    build:
      context: ./
      dockerfile: Dockerfile
    environment: # Pass environment variables to the service
      SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/hospital?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false&allowPublicKeyRetrieval=true
      SPRING_DATASOURCE_USERNAME: root
      SPRING_DATASOURCE_PASSWORD: root
      SPRING_RABBITMQ_HOST: rabbitmq
    depends_on:
      - rabbitmq
      - db
    volumes:
      - /data/VerzorgerSOAP
    ports:
      - "8080:8080"
    networks:
      - mysql_bridge
      - rabbit_mq

networks:
  mysql_bridge:
  rabbit_mq:
spring spring-boot docker rabbitmq
1个回答
1
投票

Spring Boot为某些应用程序properties提供了默认值:

spring.rabbitmq.password=guest
spring.rabbitmq.username=guest

在这种情况下,这仅仅是巧合。

将这些属性更改为其他属性,您将看到身份验证将失败。

© www.soinside.com 2019 - 2024. All rights reserved.