Search
Duplicate

๊ฒŒ์‹œํŒ ํ”„๋กœ์ ํŠธ

๊ฒŒ์‹œํŒ ํ”„๋กœ์ ํŠธ

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
๋ณต์‚ฌ

์—”ํ„ฐํ‹ฐ ์ •์˜

Repository ์ธํ„ฐํŽ˜์ด์Šค ์„ ์–ธ