Springboot 강의를 보면서 JPA 연동만 하고 자야지 하다가 1시간이나 걸렸다.
가수면 상태를 이겨가면서 성공한 프로젝트는 반드시 문제가 생기기 마련이므로 정리!
build.gradle에 의존성을 추가한다.
간혹 compile 로 의존성을 추가하는 부분이 나오는데 에러가 떠서 찾아보니,
gradle 7 버전에서는 compile과 testComplie이 deprecated 되어서
implementation과 testImplementation을 사용해야 한다고 되어있다.
mysql에 관한 의존성 추가는 아래의 내용만 추가하면 된다.
dependencies {
implementation 'mysql:mysql-connector-java'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
}
현재 진행중인 프로젝트의 build.gradle 부분.
lombok을 사용하면서 추가한 부분도 함께 포함되어 있다.
(처음 시작하면서 혼자서 얼레벌레 잘 헤쳐나가고 있다고 생각함.)
dependencies {
implementation 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'mysql:mysql-connector-java'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
}
# MySQL 설정
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# DB datasource URL
spring.datasource.url=jdbc:mysql://localhost:3306/study?useSSL=false&useUnicode=true&serverTimezone=Asia/Seoul
# JPA 쿼리문 확인
spring.jpa.show-sql=true
# DDL 정의 시 DB 고유 기능 사용
spring.jpa.hibernate.ddl-auto=update
# hibernate 동작하면서 발생한 SQL의 가독성을 높임
spring.jpa.properties.hibernate.format_sql=true
# DB user info
spring.datasource.username=root
spring.datasource.password=1234