๊ฒ์ํ ํ๋ก์ ํธ
JPA ๋ฅผ ์ฌ์ฉํ์ฌ ๊ฒ์ํ CRUD ๊ธฐ๋ฅ์ ์ ์ฉํ๋ ๊ฒ์ํ ํ๋ก์ ํธ๋ฅผ ๊ตฌํํด๋ด
๋๋ค.
1.
์ค๋น์ฌํญ
a.
DB
b.
JDK
c.
IDE
2.
์์กด์ฑ
a.
build.grdle
3.
๋ฐ์ดํฐ ์์ค
a.
application.properties
4.
ํ๋ก์ ํธ ์ค์
5.
์ํฐํฐ ์ ์
6.
Repository ์ธํฐํ์ด์ค ์ ์ธ
์ค๋น์ฌํญ
1.
DB
2.
JDK
3.
IDE
DB
์ด ํ๋ก์ ํธ์์๋ MySQL ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์ฌ์ฉํ์ฌ ๊ตฌํํด๋ณด๋๋ค.
JDK
IDE
์์กด์ฑ
1.
build.grdle
build.grdle
plugins {
id 'java'
id 'war'
id 'org.springframework.boot' version '3.4.3'
id 'io.spring.dependency-management' version '1.1.7'
}
group = 'com.aloha'
version = '0.0.1-SNAPSHOT'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
tasks.named('test') {
useJUnitPlatform()
}
Java
๋ณต์ฌ
๋ฐ์ดํฐ ์์ค
1.
application.properties
application.properties
# ๋ฐ์ดํฐ ์์ค - MySQL
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/aloha?serverTimezone=Asia/Seoul&allowPublicKeyRetrieval=true&useSSL=false&autoReconnection=true&autoReconnection=true
spring.datasource.username=aloha
spring.datasource.password=123456
Java
๋ณต์ฌ
ํ๋ก์ ํธ ์ค์
application.properties
spring.application.name=board
# ๋ฐ์ดํฐ ์์ค - MySQL
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/aloha?serverTimezone=Asia/Seoul&allowPublicKeyRetrieval=true&useSSL=false&autoReconnection=true&autoReconnection=true
spring.datasource.username=aloha
spring.datasource.password=123456
# JPA ์ค์
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
spring.jpa.database=mysql
# ๋ก๊น
๋ ๋ฒจ
# - ALL, TRACE, DEBUG, INFO, WARN, ERROR, OFF
logging.level.root=DEBUG
logging.level.org.hibernate=INFO
Java
๋ณต์ฌ




