언어·프레임워크/Spring Boot
[Spring Boot][FastCampus][Final Project] 스프링 부트를 이용한 게시판 프로그램 ② - 데이터베이스 연동 설계와 구현
DandyNow
2022. 8. 30. 00:46
728x90
반응형
과제 상세 5
데이터베이스 연동은 반드시 Spring Data JPA를 이용하여 구현합니다.
build.gradle
plugins {
id 'org.springframework.boot' version '2.7.2'
id 'io.spring.dependency-management' version '1.0.12.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
// compile 'mysql:mysql-connector-java'
implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.30'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// View using JSP
implementation 'javax.servlet:jstl'
implementation "org.apache.tomcat.embed:tomcat-embed-jasper"
}
tasks.named('test') {
useJUnitPlatform()
}
과제 상세 6
게시판 테이블과 시퀀스는 Board 엔티티에 설정된 Annotation을 기반으로 자동으로 생성되도록 합니다.
src\main\resources\application.properties
# MySQL
spring.jpa.database=mysql
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
# db source url
spring.datasource.url=jdbc:mysql://localhost:3306/fastcampus?useUnicode=true&charaterEncoding=utf-8&serverTimezone=Asia/Seoul
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=1234
# <과제 상세 6> 관련 ---------------------------
# JPA
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create
#spring.jpa.hibernate.ddl-auto=update
# Show query
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
# ----------------------------------------------
# View with JSP
spring.mvc.view.prefix=/WEB-INF/
spring.mvc.view.suffix=.jsp
728x90
반응형