ORM(Spring data jpa)

spring-data-jpa , hibernate , orm

pom.xml

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

application.propertise

spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

spring.jpa.properties.hibernate.hbm2ddl.auto=create-drop

application.yml

spring:
    datasource:
        driver-class-name: com.mysql.cj.jdbc.Driver
        password: ''
        url: jdbc:mysql://localhost:3306/test
        username: root
    jpa:
        properties:
            hibernate:
                hbm2ddl:
                    auto: create-drop

User 도메인 작성

Repository interface 작성

테스트 코드 작성

끝!

Last updated