다음의 지침 :Springfox Swagger-UI를 추가했는데 작동하지 않습니다. 무엇이 누락 되었습니까? 여기
http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api
나는 내 프로젝트에 이러한 종속성을 추가 :
compile "io.springfox:springfox-swagger2:2.7.0"
compile "io.springfox:springfox-swagger-ui:2.7.0"
과 같은 SpringFox 자신감을 구성 :
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
하지만 자신감 UI가 보인다 사용할 수 없게됩니다. 나는 시도 :
- http://localhost:8080/swagger-ui.html
- http://localhost:8080/api/swagger-ui.html
- http://localhost:8080/v2/api-docs/swagger-ui.html
내가 가진 전부입니다
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Sep 11 09:43:46 BST 2017
There was an unexpected error (type=Method Not Allowed, status=405).
Request method 'GET' not supported
및 로그에 나는 참조 :
2017-09-11 09:54:31.020 WARN 15688 --- [nio-8080-exec-6] o.s.web.servlet.PageNotFound : Request method 'GET' not supported
2017-09-11 09:54:31.020 WARN 15688 --- [nio-8080-exec-6] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
http://localhost:8080/swagger-resources 반환 : 나는 무엇을
[{"name": "default",
"location": "/v2/api-docs",
"swaggerVersion": "2.0"}]
를 놓친 거지?
액세스를 방해 할 수있는 스프링 보안 기능이 있습니까? – StanislavL
@StanislavL : 아니요, 아직 보안 기능을 활성화하지 않았습니다. – Pablo
@StanislavL : 내가 얻은 로그 오류를 추가했고 PageNotFound입니다. – Pablo