Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 그리디
- dart
- 백준
- 동적프로그래밍
- 삼성
- 해시해킹
- 26008
- 서울에서경산까지
- 스택
- 14863
- Crossfit
- 15353
- 회전하는큐
- 재귀
- BOJ
- 1로만들기2
- C++
- Python
- DP
- sw expert academy
- 4811
- spring boot
- 재귀함수
- 1781
- 15662
- 크로스핏
- BOJ14889
- D1
- 브루트포스
- Flutter
Archives
- Today
- Total
곧죽어도 콛잉
[Spring] Spring Security에서 H2-Database 사용하기 본문
1. 의존성 추가
Maven Repository: com.h2database » h2
- 최신 버전 확인
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
2. test용도로 정적 url 설정.
spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:testdb
3. 초기 테이블 설정
- schema.sql 정의하여 초기 테이블 생성하기
create table course
(
id bigint not null,
name varchar(255) not null,
author varchar(255) not null,
primary key(id)
);
- Spring Data JPA Starter를 활용할때마다 자동으로 schema.sql 파일을 가져와서 H2에 테이블을 생성함.
4. 만약 Spring-Security를 설정했다면, /h2-console 접속시 다음과 같은 오류 발생함. (h2-console이 frame 태그를 사용하는데, Spring Security가 기본적으로 이것을 막고 있음.)
http.headers().frameOptions().sameOrigin()
// 요청이 동일한 오리진에서 오는 경우, 해당 app의 frame을 허용함.
// example.com은 OK. evil.com은 허용 X.
(Spring Security의 Configuration에서 설정하면된다)
'Spring > 기본' 카테고리의 다른 글
[Spring] Spring Boot DevTools (0) | 2023.06.22 |
---|---|
[Spring] Spring Boot 컨트롤러와 Rest API (0) | 2023.06.16 |
[Spring] WEB & HTTP의 개념 (0) | 2023.06.15 |
[Spring] Spring Boot의 개요 / Framework vs Library (0) | 2023.06.14 |
Comments