[24.06.04] 내일배움캠프 34일차 JAVA TIL - h2, security 설정

2024. 6. 5. 09:20T.I.L

오늘 한 일

  • 팀 과제 발제 듣기
  • 팀 과제 기획
  • 기본 환경 구축

 

 


오늘은 일주일간 진행되는 팀 프로젝트를 기획했다.

 

뉴스피드 프로젝트

 

프로젝트 제목 : OTT괌 : OTT 계정을 공유해서 사용하기 위해 멤버를 구하는 웹 페이지

 

데이터 베이스는 H2를 사용했다.

이전에 스프링 시큐리티에서 실시간 강의를 해주신 적이 있었는데, 당시의 자료가 많은 도움이 됐다.

 

선정 이유

팀원들이 사용하는 데이터 베이스가 mariadb /  mysql 로 나누어져 별도의 설치가 필요없는 h2를 사용하기로 했다.

또 본 프로젝트는 스프링 심화 주차를 이용한 일주일의 소규모 프로젝트이기 때문에 용량이 가볍고 빠른 h2가 적합하다고 생각했다.

 

 

우리 팀은 h2의 포트를 8081으로 설정하고 사용했다.

 

초기 설계 : 

  1. 서버를 기동합니다.
  2. 브라우저에서 다음 URL로 접속합니다. http://localhost:8081/h2-console
  3. application.yml에 정의한 datasource의 계정 정보를 입력합니다.

 

application.yml 

spring:
  application:
    name: "nbcamp-lecture-spring-security-h2"
  datasource:
    url: "jdbc:h2:~/test"
    username: sa
    password: password
    driver-class-name: org.h2.Driver
  jpa:
    database-platform: org.hibernate.dialect.H2Dialect
    hibernate:
      ddl-auto: update
    properties:
      hibernate:
        show_sql: true
        format_sql: true
        use_sql_comments: true
  h2:
    console:
      enabled: true
      settings:
        web-allow-others: true

logging:
  level:
    root: DEBUG
    org.hibernate.SQL: DEBUG
    org.hibernate.type: TRACE
    org.springframework.security: DEBUG
    reactor:
      netty: DEBUG

jwt:
  secret: "036c4fe3ec667532545b9e8fa7e2a98a22f439dff102623c097715060e2da68c"
  expiry-millis: 300000 # 5분