inblog logo
|
codingb
    Spring

    블로그 프로젝트 v1 - DB 초기화하기 (더미 데이터)

    Feb 21, 2024
    블로그 프로젝트 v1 - DB 초기화하기 (더미 데이터)

    [ resourece/db/data.sql ]

    insert into user_tb(username, password, email, created_at) values('ssar', '1234', 'ssar@nate.com', now()); insert into user_tb(username, password, email, created_at) values('cos', '1234', 'cos@nate.com', now());
     

    [ application.yml ]

    sql: init: data-locations: - classpath:db/data.sql 스프링 실행할때 초기화하는 설정법
     
    defer-datasource-initialization: true ddl-auto가 된 후에 실행되게 하는 설정
     
    server: servlet: encoding: charset: utf-8 force: true session: timeout: 30m port: 8080 spring: mustache: servlet: expose-session-attributes: true expose-request-attributes: true datasource: driver-class-name: org.h2.Driver url: jdbc:h2:mem:test;MODE=MySQL username: sa password: h2: console: enabled: true sql: init: data-locations: - classpath:db/data.sql jpa: hibernate: ddl-auto: create show-sql: true properties: hibernate: format_sql: true defer-datasource-initialization: true
    notion image
    Share article

    codingb

    RSS·Powered by Inblog