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 | 31 |
Tags
- 배열의 배열
- 다차원 배열
- msa
- 데이터타입 #변수
- 런타임 복잡도
- do-while
- 고수준
- 언매니지드
- 후조건
- SWAGGER
- decimal
- 공학수학
- 포큐
- 함수의 범위
- comp1000
- 개체지향
- 매니지드
- out 매개변수
- 접두사
- 논리 연산자
- 접미사
- jit
- C# Assert
- 1일 1커밋
- Github
- 저수준
- args
- COMP2500
- 오픈쉬프트
- 선조건
Archives
- Today
- Total
내 생각대로 정리하는 블로그
[ SPRING SECURITY + SWAGGER ] 연동방법 본문
1. gradle dependencies에 아래 내용을 추가해준다.
- buil.gradle
- maven 프로젝트는 properties 파일에 추가하면 된다. 다른 형식으로...
implementation 'io.springfox:springfox-boot-starter:3.0.0'
implementation 'io.springfox:springfox-swagger-ui:3.0.0'
2. SwaggerConfig.java을 추가한다.
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
@Configuration
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.OAS_30)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
3. 일반적인 Spring framework라면 1번과 2번만 적용해줘도
http://127.0.0.1:8080/swagger-ui/ 로 접속해서 확인이 가능하다.
하지만 security의 ignoring에 swagger 관련 url을 등록해주지 않으면 ui를 불러올때 모두 막혀 흰페이지만 확인하게 될것이다. 그렇기에
/swagger-ui/**
/swagger-resources/**
/v3/api-docs
등록해주면 정상 작동하게 된다.
- SecurityConfig.java
@Override
public void configure(WebSecurity web) {
web.ignoring()
.antMatchers(
"/favicon.ico"
,"/error"
,"/swagger-ui/**"
,"/swagger-resources/**"
,"/v3/api-docs"
)
}
*참고 블로그: https://blog2.deliwind.com/20201127/java-swagger-ui-3-0-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0/
'IT공부 > JAVA' 카테고리의 다른 글
자바 데이터 타입, 변수 (0) | 2021.05.05 |
---|---|
JVM이란? (0) | 2021.04.28 |
Comments