ARCHIVES

태그

신고하기

상단 메뉴 페이지

기본 콘텐츠로 건너뛰기

스프링부트 with JPA 블로그, Swagger 2부


스웨거 2.6.1 버전이 가장 편히 보기 쉽지만.
최신 버전이 3.0.0 이라서 업데이트 하고 확인 해보았다.

변경된 부분이 많다. 
참고: https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api

1. pom.xml 파일에 스웨거 설정 변경.
영문사이트를 검색하다 보니, 
깃허브 : https://github.com/springfox/springfox

스프링부트 프로젝트는 아래의 dependency 하나로 가능 하다.

         <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>

2. SwaggerConfig.java 파일 변경
    @EnableSwagger2 어노테이션 제거.

3. SecurityConfig.java 를 설정 했다면 리소스 필터 변경
    "/swagger-ui/**" 추가

@Override

public void configure(WebSecurity web) throws Exception {

    // swagger 관련 리소스 시큐리티 필터 제거

    web.ignoring().antMatchers(

            "/v2/api-docs",

            "/swagger-resources/**",

            "/swagger-ui.html",

            "/swagger-ui/**"

            "/webjars/**",

            "/swagger/**");

}


4. 접속 경로 변경

http://localhost:8080/swagger-ui/index.html


업데이트 완료!!

댓글