들어가며...
마지막으로 설정 부분 및 초기 SQL 관련 부분의 내용을 끝으로 해당 프로젝트의 전체 글을 마무리 하고자 합니다.
- Table of Contents
- application.yml, data.sql
application.yml, data.sql
● application.yml
어플리케이션의 설정 부분입니다. 경로는 "src/main/resources"에 있으며 초기에는 "application.properties"로 되어 있었을 것입니다. 무엇을 사용하여도 무방하나 전 yaml 포맷을 선호하여 파일명을 변경하였습니다.
아래는 전체 설정 내요입니다.
# ==================================================================
# Data Source
# ==================================================================
spring:
datasource:
url: jdbc:h2:file:/Users/leo/Downloads/h2-security
username: sa
password:
driver-class-name: org.h2.Driver
# ==================================================================
# Data Source : keep the connection alive if idle for a long time (needed in production)
# ==================================================================
tomcat:
test-while-idle: true
validation-query: SELECT 1
# ==============================================================
# = Initialize the database using data.sql script
# ==============================================================
initialization-mode: always
# ==================================================================
# h2 database
# ==================================================================
h2:
console:
enabled: true
path: /h2
# ==================================================================
# thymeleaf
# ==================================================================
thymeleaf:
cache: false
# ==================================================================
# show a log of SQL query
# ==================================================================
jpa:
show-sql: true
properties:
hibernate.format_sql: true
# ==================================================================
# Hibernate ddl auto (create, create-drop, update)
# ==================================================================
hibernate:
ddl-auto: update
# ==============================================================
# = The SQL dialect makes Hibernate generate better SQL for the chosen database
# ==============================================================
database-platform: org.hibernate.dialect.H2Dialect
# ==============================================================
# = Logging
# ==============================================================
logging:
level:
com.demo.security : debug
대부분의 설정은 H2 database에 관한 것입니다. 이전에 H2 console 연동관련 글이 있어 각 프로퍼티의 내용은 해당 글을 참조하시면 될 듯 합니다.
2020/03/11 - [Programming/Spring Boot] - [Spring Boot][H2 Database 연동 2/2] H2 Console 사용 및 설정
[Spring Boot][H2 Database 연동 2/2] H2 Console 사용 및 설정
들어가며... 지난번 포스팅에 이어 이번에는 H2 database 및 JPA 설정 방법에 대해 알아보도록 하겠습니다. Table of Contents H2 console 사용하기 H2 database 설정 이전글 참조 : 2020/03/10 - [Programming/S..
u2ful.tistory.com
● data.sql
application.yml의 경로와 동일한 위치에 "data.sql"이라는 파일이 두었습니다. 이는 어플리케이션이 실행될 때 마다 해당 SQL문을 수행하게 됩니다. 따라서 개발할 때만 사용하시면 용도로 사용하시는 것이 좋습니다.
본 글에서는 사용자의 유형별 권한을 등록하는 SQL문이 포함되어 있습니다.
MERGE INTO ROLES
KEY(ID)
VALUES
(1, 'ROLE_ADMIN'),
(2, 'ROLE_MANAGER'),
(3, 'ROLE_GUEST');
마무리...
이상으로 폼기반 로그인 및 회원가입을 위한 Spring Security에 대해서 알아보았습니다.
해당 프로젝트에 나오는 모든 기술을 완벽하게 파악하고 있는 것이 아니라서 단계별로 글을 나누고 두서 없이 정리한 부분이 있겠습니다. 해당 글이 Spring Security 이해하는데 조금이라도 도움이 되었으면 합니다.
다음은 해당 프로젝트의 전체 소스코드가 있는 Github 주소입니다.
https://github.com/ykson/spring-boot-security
ykson/spring-boot-security
Spring Boot Security Sample Project. Contribute to ykson/spring-boot-security development by creating an account on GitHub.
github.com
U2ful은 ♥입니다. @U2ful Corp.
'Programming > Spring Security' 카테고리의 다른 글
[Spring Security][회원가입 및 로그인 예제 8/9] View 구현 (1) | 2020.03.31 |
---|---|
[Spring Security][회원가입 및 로그인 예제 7/9] Controller 구현 (0) | 2020.03.23 |
[Spring Security][회원가입 및 로그인 예제 6/9] AuthenticationSuccessHandler & AuthenticationFailureHandler 구현 (3) | 2020.03.23 |
[Spring Security][회원가입 및 로그인 예제 5/9] Web Security Configuration 설정 (1) | 2020.03.23 |
[Spring Security][회원가입 및 로그인 예제 4/9] Service Layer 구현 (0) | 2020.03.19 |