민뭉아치
민뭉아치
민뭉아치
전체 방문자
오늘
어제
  • 분류 전체보기 (62)
    • ㅁㅁㅇㅊ's Life (0)
      • Diary (1)
      • Certification (6)
      • English (1)
      • 독서 (1)
    • Algorithm (25)
    • Web (2)
    • Language (3)
      • JavaScript (1)
      • JAVA (2)
    • Spring boot (9)
    • Cloud (0)
    • DevOps (1)
    • Trouble Shooting (6)
    • 개발환경 (3)
    • 짤막IT지식 (4)

블로그 메뉴

  • 홈
  • 깃허브
  • 방명록

공지사항

인기 글

태그

  • Spring
  • Algorithm
  • 백준알고리즘
  • 알고리즘
  • 백준
  • 자바
  • Java
  • 코딩테스트
  • 자격증
  • 정보처리기사

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
민뭉아치

민뭉아치

Spring boot와 h2 Database 연동 오류발생
Trouble Shooting

Spring boot와 h2 Database 연동 오류발생

2022. 4. 10. 01:58

1. 문제 사항

Embedded H2 DataBase를 웹으로 연결하니 localhost가 거부했다는 페이지가 떴다.

DB 설정 application.yml

spring:
  datasource:
    driver-class-name: org.h2.Driver
    url: jdbc:h2:mem:testdb
    username: sa
    password:
  jpa:
    hibernate:
      ddl-auto: create
    show-sql: true
    properties:
      hibernate:
        dialect: org.hibernate.dialect.H2Dialect
  h2:
    console:
      enabled: true
      path: /h2-console
      settings:
        web-allow-others: true

2. 원인

Spring Boot Project에 Security를 적용하였는데 Security가 접근을 제한하였다.

 

3. 해결

SecurityConfig 클래스에 configure 메서드를 오버라이드 하여 웹에서 h2-console에 접근하는 것을 허용하도록 설정한다.

    @Override
    public void configure(WebSecurity web) throws Exception {
        web.ignoring().antMatchers("/h2-console/**");  // --> 추가
    }

4. 참고

https://yuja-kong.tistory.com/126

 

[SpringBoot] h2-console 웹 접근안될 때 해결 방법

Springboot에서 H2를 적용하고, 웹 콘솔 사용여부 true 처리하였는데 웹 접근이 안되는 상황을 겪었다. 찾아보니 원인은 아주 간단하지만 놓치기 쉬운 부분이었다. application.properties 의 h2 적용 상태 #

yuja-kong.tistory.com

 

반응형

'Trouble Shooting' 카테고리의 다른 글

리소스를 HTTPS 프로토콜 호출로 인한 ERR_SSL_PROTOCOL_ERROR 발생, Mixed Content  (0) 2024.04.17
Spring Boot Jpa IllegalArgumentException 에러  (2) 2022.05.18
AWS EC2 Gradle 배포 시 멈춤현상  (0) 2022.05.04
QLRM 네이티브 쿼리 DTO type 오류  (0) 2022.04.14
[Hibernate Error] TransientPropertyValueException : object references an unsaved transient instance  (0) 2022.03.21
    'Trouble Shooting' 카테고리의 다른 글
    • Spring Boot Jpa IllegalArgumentException 에러
    • AWS EC2 Gradle 배포 시 멈춤현상
    • QLRM 네이티브 쿼리 DTO type 오류
    • [Hibernate Error] TransientPropertyValueException : object references an unsaved transient instance
    민뭉아치
    민뭉아치
    Do Better Today Than You Were Yesterday

    티스토리툴바