-
Spring Boot 3.0.2) Swagger 3.0 연동하기Programing Language/Java 2023. 2. 16. 17:28728x90반응형
- 필요 dependency
//pod.xml <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> <version>2.0.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> </dependency>
- Config 파일
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.service.ApiInfo; 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) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo(){ return new ApiInfoBuilder() .title("test") .description("description") .version("1.0.0") .build(); } }
- 접속 주소 : http://localhost:8080/swagger-ui/index.html
- 추가적인 기능들은 공식문서 참고!!
공식문서: https://springdoc.org/v2/
도움 되셨다면 하단의 광고 클릭 센스!!
728x90반응형'Programing Language > Java' 카테고리의 다른 글
Spring Boot) Controller와 Service 사용방법 (기초) (0) 2023.02.16 Java ) Mac OS에 Java JDK 설치하기 (0) 2020.03.27