반응형
인메모리 데이터베이스인 h2를 사용하려는데 localhost:8088/h2-console 로 들어가도 로그인 화면만 떴다.
화면이 spring security를 사용했을때 자동으로 넘어가는 페이지랑 같아서 의심은 했는데 맞았다..
1차적으로 spring security를 의존성에서 제외시키고 다시 실행하니 잘 실행됐다.
이후 찾아보니 WebSecurityConfigurerAdapter를 상속받은 스프링시큐리티 컨피겨(설정) 클래스가
h2-console 주소를 무시하도록 설정해야 한다.
참고한 블로그: https://blog.naver.com/yl9517/222337349598
[SpringBoot] Spring Security란?, 시큐리티 보안 설정
spring Security spring 기반의 애플리케이션의 보안(인증과 권한, 인가 등)을 담당하는 스프링 하위 프레...
blog.naver.com
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@EnableWebSecurity
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter{
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/").permitAll()
.and()
.csrf()
.ignoringAntMatchers("/h2-console/**");
}
}
h2, datasource, jpa 설정
spring:
h2:
console:
enabled: true
path: /h2-console
datasource:
driver-class-name: org.h2.Driver //같게
url: jdbc:h2:mem:testdb //같게
username: sa //같게
password:
jpa:
database-platform: org.hibernate.dialect.H2Dialect
hibernate:
ddl-auto: update
naming:
# cammel case 사용시 필요한 설정
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
위처럼 설정했을시 저 화면에서 //같게 주석 부분이 일치하도록 해야 한다.
반응형
댓글