티스토리 뷰

728x90
반응형
SMALL

Swagger UI 연동

1. pom.xml 에 dependency 추가

<dependency>  
    <groupId>io.springfox</groupId>  
    <artifactId>springfox-swagger2</artifactId>  
    <version>2.9.2</version>  
</dependency>  
<dependency>  
    <groupId>io.springfox</groupId>  
    <artifactId>springfox-swagger-ui</artifactId>  
    <version>2.9.2</version>  
</dependency>

2. Swagger Configuartion에 @Bean 추가

@Configuration  
@EnableSwagger2  
public class SwaggerConfiguration {  

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

3. controller 추가

@RestController  
public class SampleController {  

    @GetMapping("/sample")  
    public String sample(String sampleStr) {  
        return sampleStr + sampleStr;  
    }  
}

4. http://localhost:8088/swagger-ui.html# 로 swagger 연동 확인

728x90
반응형
LIST

'Spring boot study > 8. ETC..' 카테고리의 다른 글

SSL/TLS Self Certificate  (0) 2022.05.12
Spring boot undertow 적용  (0) 2021.11.15
Spring Cloud Config Client 정리  (0) 2021.11.09
Spring Cloud Config Server 정리  (0) 2021.11.09
Spring Batch 정리  (0) 2021.06.17
댓글
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
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
글 보관함