Paper.Yellow
DB변경 - h2 > MariaDB 본문
1. build.gradle 코드 변경
plugins {
id 'org.springframework.boot' version '2.7.5'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
}
group = 'site.metacoding'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.mariadb.jdbc:mariadb-java-client'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
각각의 버전이 맞지 않으면 충돌이 날 수 있다.
스프링부트는 버전을 따로 적지 않으면 출동하지 않게 맞춰서 적용해준다.
2. application.yml 코드 변경
server:
port: 8000
servlet:
context-path: /
spring:
datasource:
url: jdbc:mariadb://127.0.0.1:3306/greendb
driver-class-name: org.mariadb.jdbc.Driver
username: green
password: green1234
jpa:
hibernate:
ddl-auto: create
output:
ansi:
enabled: always
logging:
level:
root: DEBUG
3. DB 초기화
- 서버를 실행해서 DB 연결 후 DB 초기화 하기
DROP DATABASE greendb;
CREATE DATABASE greendb;
'JPA' 카테고리의 다른 글
JPA 시간 관련 Entity 생성 (0) | 2022.12.05 |
---|---|
하이퍼네이트 초기설정 (0) | 2022.10.24 |
스프링부트로 테이블 생성하기 (0) | 2022.10.21 |
새 프로젝트 시작, 스프링부트 JPA 세팅 (0) | 2022.10.21 |
Visual Studio Code - 기본 세팅 (0) | 2022.10.21 |