- FE: приложение Spring Boot 3, которое отображает информацию пользователю li>
BE: приложение Spring Boot 3, которое подключается к базе данных и отправляет информацию в FE - MySql : база данных, в которой хранятся данные
- Сервер конфигурации: Приложение Spring Cloud, которое хранит конфигурации сервисов на Github.
Код: Выделить всё
# Port
server.port=8081
# Service Name
spring.application.name=be
# Config Server
spring.config.import=configserver:http://localhost:8888
Код: Выделить всё
be:
image: be-image:0.0.1
container_name: be-container
build:
context: ./springcloud-fe-thymeleaf-be-springboot-db-sql-mysql-config_BE
dockerfile: Dockerfile
depends_on:
config:
condition: service_healthy
ports:
- 8081:8081
environment:
spring.config.import: configserver:http://config:8888
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8081/actuator/health"]
interval: 10s
timeout: 10s
retries: 5
start_period: 10s
networks:
- helloworld-network
Код: Выделить всё
docker-compose up -d --build
Код: Выделить всё
2025-01-20 17:02:36 Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8888/be/default": Connection refused
2025-01-20 17:02:36 at org.springframework.web.client.RestTemplate.createResourceAccessException(RestTemplate.java:926)
2025-01-20 17:02:36 at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:906)
Проверено на:
- Java: 23
- Spring Boot: 3.4.1
- Spring Cloud: 2024.0.0
- Mvn: 3.9.6
Есть идеи, почему свойство spring.config.import не перезаписывается переменными среды из Docker, Docker Compose или Kubernetes?
Подробнее здесь: https://stackoverflow.com/questions/793 ... written-by
Мобильная версия