Spring
Spring_MySQL 연결_gradle
owoowo
2023. 3. 22. 22:48
728x90
1. 의존성 찾기
https://mvnrepository.com/artifact/com.mysql/mysql-connector-j/8.0.32
2. build.gradle에 의존성 추가
3. application.yml
spring:
# MySQL
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: ${mysql.url}
username: ${mysql.username}
password: ${mysql.password}
4. ENV 파일 작성
# Mysql
mysql.url=jdbc:mysql://url:포트/DB이름?serverTimezone=UTC&characterEncoding=UTF-8
mysql.username=아이디
mysql.password=비밀번호
5. Spring Env 설정
https://lazybones1.tistory.com/12
Spring_env 파일 설정
1. .gitignore 설정 ### env ### !**/properties/ env.properties 2. Spring에서 설정 @Configuration @PropertySources(@PropertySource("classpath:properties/env.properties")) //env.propoerties 파일 소스 등록 public class EnvConfig { } 3. env.properti
lazybones1.tistory.com