아틴
Atin
아틴
전체 방문자
오늘
어제
  • 분류 전체보기 (460)
    • Devlopment (246)
      • 정리 글 (20)
      • MicroServices (0)
      • Reactive, Concurrenc.. (12)
      • Java (44)
      • Spring (20)
      • C,C++,Ruby,Python (52)
      • Mobile (39)
      • Web (35)
      • Tip & Info (14)
      • Unit Test (7)
    • Infra (44)
      • OS (21)
      • RDBMS (13)
      • NoSQL&Cache (5)
      • AWS (4)
    • Computer Science (11)
    • Etc (156)

블로그 메뉴

  • Home
  • Guestbook

공지사항

인기 글

태그

  • 여행
  • 정읍
  • CSS
  • 해킨토시
  • Python
  • mysql
  • 안드로이드
  • 아이폰
  • jsp
  • Linux
  • 던젼 앤 드래곤즈
  • javascript
  • Dungeons & Dragons
  • TRPG
  • C
  • 자바
  • Java
  • 전라도
  • Ruby on Rails
  • Android

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
아틴

Atin

Devlopment/Spring

SpringBoot에서 H2 DB 관리자 UI 접속하기

2015. 9. 22. 14:17
반응형

SpringBoot에서 H2를 사용할 경우 구동시에 DB상태를 보고 싶었다.

가령 php my admin처럼 말이다. 찾아보니 이게 있는데 생각보다 간단하고 신기하다.


Ref에 있는 해외 글에서 방법을 찾았다.


1. Maven, Gradle 추가

Maven : 

<dependency>

    <groupId>com.h2database</groupId>

    <artifactId>h2</artifactId>

</dependency>


Gradle

compile("com.h2database:h2")




2. H2 Servlet 추가

import org.h2.server.web.WebServlet;

import org.springframework.boot.context.embedded.ServletRegistrationBean;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;


@Configuration

public class WebConfiguration {

    @Bean

    ServletRegistrationBean h2servletRegistration(){

        ServletRegistrationBean registrationBean = new ServletRegistrationBean( new WebServlet());

        registrationBean.addUrlMappings("/console/*");

        return registrationBean;

    }

}



3. SecurityConfiguration 추가

import org.springframework.context.annotation.Configuration;

import org.springframework.security.config.annotation.web.builders.HttpSecurity;

import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;


@Configuration

public class SecurityConfiguration extends WebSecurityConfigurerAdapter {


    @Override

    protected void configure(HttpSecurity httpSecurity) throws Exception {

        httpSecurity.authorizeRequests().antMatchers("/").permitAll().and()

                .authorizeRequests().antMatchers("/console/**").permitAll();


        httpSecurity.csrf().disable();

        httpSecurity.headers().frameOptions().disable();

    }


}




4. 구동 및 접속

http://localhost:8080/console/





Reference

[1] Spring guru (https://springframework.guru/using-the-h2-database-console-in-spring-boot-with-spring-security/)







반응형

'Devlopment > Spring' 카테고리의 다른 글

Spring Security custom expression  (0) 2017.02.01
Spring Security 관련 레퍼런스 정리  (0) 2017.02.01
Jackson에서 null string 안 보이게 설정  (1) 2016.08.12
JPA Hibernate 사용 중 ORA-00001: 무결성 제약 조건( ORA-00001 에러  (0) 2016.06.07
Spring에서 기본적인 component-scan 설정  (0) 2016.05.23
Spring에서 Pageable, Valid 설정 유의 설정  (0) 2016.05.23
QueryDSL  (0) 2016.05.17
Hibernate Dialect (ORA-00933 Pagable error)  (0) 2016.05.17
JPA, Hibernate 속성 정리  (0) 2016.02.29
SpringBoot application.properties H2 DB설정  (0) 2016.02.12
    'Devlopment/Spring' 카테고리의 다른 글
    • QueryDSL
    • Hibernate Dialect (ORA-00933 Pagable error)
    • JPA, Hibernate 속성 정리
    • SpringBoot application.properties H2 DB설정
    아틴
    아틴

    티스토리툴바