κ²μν νλ‘μ νΈ
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
볡μ¬