[Spring] Spring Boot MySQL 연동 - application.properties

Narcoker·2025년 8월 4일

Spring

목록 보기
18/20

Spring Boot MySQL 연동

build.gradle depenencies 추가

  • implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
  • runtimeOnly 'com.mysql:mysql-connector-j'
dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-data-jdbc' // 추가
	implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	compileOnly 'org.projectlombok:lombok'
	developmentOnly 'org.springframework.boot:spring-boot-devtools'
	runtimeOnly 'com.mysql:mysql-connector-j' // 추가
	annotationProcessor 'org.projectlombok:lombok'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

application.properties 파일에 다음 코드 추가

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://[IP]:[포트번호]/[DB이름]?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul
spring.datasource.username=[본인계정이름]
spring.datasource.password=[본인계정비밀번호]
profile
열정, 끈기, 집념의 Frontend Developer

0개의 댓글