꼬물꼬물

[18강] User 테이블 생성 본문

코딩/Blog

[18강] User 테이블 생성

멩주 2022. 1. 20. 02:42

@Entity는 table을 가리킨다.

application.yml > jpa가 제공하는 기본 넘버링 전략을 사용하지 않겠다.

 

@Id @GerneratedValue @Column @ColumnDefault @CreationTimestamp

 

application.yml > jpa

테이블이 이미 존재해도 프로젝트 실행마다 새로 만들겠다.

나중에는 update로 설정해야 한다.

 

ctrl+alt+delete의 작업 관리자에서 MySQL80이 돌고 있는 것을 확인한 후, 프로젝트 실행

결과
application.yml > jpa 위의 이미지가 보이는 이유는 true로 설정했기 때문이다.
@Entity로 table 생성시 변수명 그대로 필드를 만들어준다.

 

application.yml

server:
  port: 8000
  servlet:
    context-path: /blog
    encoding:
      charset: UTF-8
      enabled: true
      force: true
    
spring:
  mvc:
    view:
      prefix: /WEB-INF/views/
      suffix: .jsp
      
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/blog?serverTimezone=Asia/Seoul
    username: cos
    password: cos1234
    
  jpa:
    open-in-view: true
    hibernate:
      ddl-auto: create
      naming:
        physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
      use-new-id-generator-mappings: false
    show-sql: true
    properties:
      hibernate.format_sql: true

  jackson:
    serialization:
      fail-on-empty-beans: false

// JPA == ORM
// ORM -> JAVA(다른언어) Object를 테이블로 매핑해주는 기술

'코딩 > Blog' 카테고리의 다른 글

[21~3 강] 연관관계 주인  (0) 2022.01.20
[20강] Board, Reply 테이블 생성  (0) 2022.01.20
[17강] Yaml/Yml 설정  (0) 2022.01.20
[16강] Lombok  (0) 2022.01.20
[13강] http 요청  (0) 2022.01.19