swagger설정중에 갑자기 에러가 발생을 했다.
이 부분은 제일 아래 부분에서 다룰 것이다. 먼저 스웨거의 의존성부터 해보자!
개발을 하다보면 api를 정리해야한다. 이를 자동화해주는 문서가 swagge이다. swagger설정에대해 알아보자.
dependencies {
implementation 'io.springfox:springfox-boot-starter:3.0.0'
}
SwaggerConfiguration java파일
@Configuration
public class SwaggerConfiguration {
@Bean
public Docket api() {
return new Docket(DocumentationType.OAS_30)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Swagger_Instagram_clone")
.description("SwaggerConfig")
.version("3.0")
.build();
}
}
http://localhost:9801/swagger-ui/#/test-controller/getIntUsingGET 에 접속하면
이런식으로 뜬다.
만약 오류가 뜬다면, 스웨거의 버전문제이다. 2.6버전 부터 오류가 뜰 수 있는데
그러면 application.properties에
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
얘를 추가해주면 된다.