먼저 test용 docker를 docker-compose를 사용해서 간단히 구축했다.

 

그런데... DB connection이 안된다...

 

Caused by: java.net.ConnectException: Connection refused (Connection refused)

 

흠... 구글링 잘 알되고 (키워드가 뭔가 없었던 것 같다..) application.yml과 docker-compose.yml을 다시 훑어 봐도 문제는 없어 보였다.

 

예전 기억을 떠올리고 떠올리다가 번개처럼 스친 기억!

---
spring:
  profiles: dev
# ===============================
# = DATA SOURCE
# ===============================
  datasource:
    hikari:
      driver-class-name: com.mysql.cj.jdbc.Driver
      jdbc-url: jdbc:mysql://localhost:3306/vermont
      ....

평소 같았으면 전혀 문제 없는 내용....

version: '3'

services:
  db:
    image: mysql:5.7
    restart: always
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    environment:
      MYSQL_ROOT_PASSWORD: XXXXX
      MYSQL_USER: XXXXX
      MYSQL_PASSWORD: XXXXX
      MYSQL_DATABASE: vermont
    volumes:
      - db-data:/var/lib/mysql
    ports:
      - 3306:3306
    expose:
      - 3306
  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080
  vermont:
    image: vermont
    restart: always
    ports:
      - 8888:8888
    depends_on:
      - db
volumes:
  db-data:

그러나 docker-compose로 구성하면 다른 얘기가 된다.

위와 같이 services 아래 서비스 이름을 지정하게 되는데 connection url도 서비스 이름으로 접근해야 한다.

그래서 jdbc:mysql://localhost/vermont...가 아닌 jdbc:mysql://db/vermont....로 바꿔야 한다.


알고 있던 내용이었는데... 역시 노트 해놓지 않으니 1시간 허비... 구글링도 잘 못찾았던 것 같다. 노트노트노트!

'Operating System > Docker | Kubernetes' 카테고리의 다른 글

npm ERR! code ENOENT  (0) 2020.11.11
docker-compose react sh: react-scripts: not found  (0) 2020.09.19

요즘 프로젝트 setup부터 잔업무까지 몸이 10개라도 모자른다.

그런데 티비에 나오는 유명한 사람들은 왜이리 똑똑하고 일도 잘하는것 같지?

얼마전 유퀴즈에 나온 PUBG 김창한대표, 하트시그널에 나온 천인우씨, sns에 알려진 개발자 셀럽(?)분들을 보면 다들 천재같다.

이럴때마다 드는 생각....

 

나도 천재이고 싶다. ㅜㅠ

'Doodle' 카테고리의 다른 글

브레빌 870  (1) 2020.07.10
탄천은 사랑입니다.  (0) 2020.06.12
10 Communication Patterns Used by Great Leaders  (0) 2020.05.08
내가 그의 이름을 불러주었을 때  (0) 2020.04.22

https://martinfowler.com/articles/microservice-testing/

 

Testing Strategies in a Microservice Architecture

The microservice architectural style presents challenges for organizing effective testing, this deck outlines the kinds of tests you need and how to mix them.

martinfowler.com

MSA에서 test전략

+ Recent posts