Spring

[Spring] AWS RDS - Spring boot ( MariaDB ) 프로젝트 연결 (2)

밀27 2024. 6. 2. 02:23

* 스프링 부트 (Spring Boot)

 - build.gradle : mariadb 의존성 추가

dependencies {

	runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'

}

 - application.properties : 데이터베이스(mariaDB) 연결정보와 관련 설정 

# AWS 연동
# JDBC 드라이버 클래스 이름
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
# 데이터베이스 URL
spring.datasource.url=jdbc:mariadb://엔드포인트/데이터베이스_이름
# 데이터베이스 사용자 이름
spring.datasource.username=root
# 데이터베이스 비밀번호
spring.datasource.password=비밀번호

#로컬서버
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
# 데이터베이스 URL
spring.datasource.url=jdbc:mariadb://localhost:3306/데이터베이스_이름
# 데이터베이스 사용자 이름
spring.datasource.username=root
# 데이터베이스 비밀번호
spring.datasource.password=비밀번호

 - Git 저장소에 올릴 때 ( 보안 )

  • application-aws.properties
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url=jdbc:mariadb://엔드포인트/데이터베이스_이름
spring.datasource.username=root
spring.datasource.password=비밀번호
  • application.properties
# application.properties
spring.profiles.include=aws
  • .gitignore
### AWS ###
application-aws.properties