공부하는 스누피

[Spring Boot] Boot에서 DataSource 사용하는 법 본문

Web/Spring

[Spring Boot] Boot에서 DataSource 사용하는 법

커피맛스누피 2021. 8. 11. 13:17

Gradle 설정

 // https://mvnrepository.com/artifact/mysql/mysql-connector-java
 implementation 'mysql:mysql-connector-java:8.0.16'

application.properties 설정

# datasource config
spring.datasource.url=jdbc:mysql://localhost/tobyspring
spring.datasource.username=integer
spring.datasource.password=1234
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

Dao에 DataSource import

import javax.sql.DataSource;
Comments