1. build.gradle 추가 및 변경하기
2. properties 추가 및 변경하기
-. id/계정 관련 확인해서 변경하기
-. 테이블명 확인하기
3. h2idiSQL로 DB 생성하고 테이블 생성하기
ex) build.gradel -> 변경후 새로고침 필수
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
//추가
developmentOnly 'org.springframework.boot:spring-boot-devtools'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
implementation 'org.commonmark:commonmark:0.21.0'
//implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
//implementation 'org.springframework.boot:spring-boot-starter-jdbc'
//runtimeOnly 'com.mysql:mysql-connector-j'
}
ex) properties
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/mybo_db2?serverTimezone=UTC&useSSL=false
spring.datasource.username=root
spring.datasource.password=1234
spring.jpa.database=mysql
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
logging.level.org.hibernate=info
ex) heidsql
쿼리문
#1.DB 생성
CREATE DATABASE mybo_db2;
#2.테이블 생성
CREATE TABLE board (
board_no INT NOT NULL AUTO_INCREMENT,
title VARCHAR(200) NOT NULL,
content TEXT NULL,
writer VARCHAR(50) NOT NULL,
reg_date TIMESTAMP NOT NULL DEFAULT NOW(),
PRIMARY KEY (board_no)
);
'4.Database' 카테고리의 다른 글
DB 테이블 실습 (1) | 2023.12.05 |
---|