1. Docker 설치
Windows
Get started with Docker for Windows. This guide covers system requirements, where to download, and instructions on how to install and update.
docs.docker.com
docker --version
docker-compose --version
설치 후, 터미널에서 위의 명령어로 버전 확인.
2. Docker compose 생성
프로젝트 루트 디렉토리에 docker-compose.yml 파일 생성
services:
mysql:
image: mysql:8.0
container_name: <<mysql-db>>
restart: always
environment:
MYSQL_ROOT_PASSWORD: <<rootpassword>>
MYSQL_DATABASE: <<myapp>>
MYSQL_USER: <<user>>
MYSQL_PASSWORD: <<password>>
ports:
- "3306:3306"
volumes:
- mysql-data:/var/lib/mysql
networks:
- msa-network
volumes:
mysql-data:
networks:
msa-network:
driver: bridge
3. docker 데스크탑 APP 실행
4. 컨테이너 시작
docker-compose up -d mysql
터미널에서 위의 명령어를 실행하여 컨테이너를 시작한다.
docker ps
위의 명령어를 사용하거나, 데스크탑 APP을 사용하여 실행 상태를 확인한다.
5.theme-service 생성
우선 구조를 이렇게 만들었다.
6. build.gradle 작성
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'com.mysql:mysql-connector-j'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
이러한 의존성을 추가했다.
7. application.yml 작성
서버 설정, mysql 설정과 jpa 설정, eureka 서버 설정을 해주었다.
리포지터리로 데이터베이스 관리하기 (2) (0) | 2025.02.02 |
---|---|
리포지터리로 데이터베이스 관리하기 (1) | 2025.01.28 |
테이블 매핑하기 (0) | 2025.01.27 |
JPA 데이터베이스 사용하기 (1) | 2025.01.27 |
웹 만들어보기 (0) | 2025.01.20 |