Programing Language/Java
Spring Boot 3.0.2) Swagger 3.0 연동하기
Jude_Song
2023. 2. 16. 17:28
728x90
반응형
- 필요 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
반응형