반응형
250x250
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 |
Tags
- Jenkins
- aws cicd
- node
- 도커
- java bigdecimal
- Airflow
- bootstrap
- COALESCE
- kubeflow
- Python
- codepipeline
- aws
- Kafka
- chartjs
- Spring Error
- codebuild
- AWS CI/CD 구축하기
- codedeploy
- redis
- codedeploy error
- or some instances in your deployment group are experiencing problems.
- chart.js
- JavaScript
- SQL
- docker
- VPN
- PostgreSQL
- IntelliJ
- Spring
- Flux
Archives
- Today
- Total
Small Asteroid Blog
[Spring Swagger3.0] spring boot에 Swagger 3.0 실습 예제 본문
728x90
의존성 추가
implementation "io.springfox:springfox-boot-starter:3.0.0"
implementation "io.springfox:springfox-swagger-ui:3.0.0"
SwaggerConfig.java 파일 추가
@Configuration
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.OAS_30)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
- Docket : swagger 설정에 핵심이 되는 Bean
- apis : api 스펙이 작성되어 있는 패키지(controller) 지정
- paths : apis에 있는 API 중 특정 path 선택
Controller 생성
@RestController
public class TestController {
@GetMapping("/api/hello1")
public String hello1() {
return "hello";
}
@GetMapping("/api/hello2")
public String hello2(@RequestParam String param) {
return param;
}
}
- 접속 url
ttp://localhost:8080/swagger-ui/index.html
728x90
반응형