본문 바로가기
IT/Spring

2021-07-27-Swagger

by 봉즙 2023. 2. 28.

layout : post
title : "Swagger 적용"

category : Spring

@EnableOpenApi 추가

@EnableOpenApi
@SpringBootApplication
public class AlbaCheckerApplication {

    public static void main(String[] args) {
        SpringApplication.run(AlbaCheckerApplication.class, args);
    }
}

grade 추가

// https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui
    implementation 'io.springfox:springfox-swagger-ui:3.0.0'
    // https://mvnrepository.com/artifact/io.springfox/springfox-swagger2
    implementation 'io.springfox:springfox-swagger2:3.0.0'
    // https://mvnrepository.com/artifact/io.springfox/springfox-boot-starter
    implementation 'io.springfox:springfox-boot-starter:3.0.0'

스웨거 설정 파일 추가

@Configuration
@EnableSwagger2
public class SwaggerConfiguration {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .build()
                .useDefaultResponseMessages(false)
                ;
    }
}

3.0 이상은 http://localhost:8080/swagger-ui/index.html 로 접속한다.

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

2021-09-01-flyway  (0) 2023.02.28
2021-08-23-EntityGraph  (0) 2023.02.28
2021-06-30-Header-language  (0) 2023.02.28
2021-06-10-TimeZone-setting  (0) 2023.02.28
2021-06-09-Memoery-setting  (0) 2023.02.28

댓글