2017-02-20 1 views
0

스프링 부트 RESTful 웹 서비스와 함께 Swagger 2.0을 사용하여 문서를 생성하고 싶습니다. 나는 이것에 대한 답을 찾기 위해 꽤 많은 것을 조사했다. 기본적으로 컨트롤러 집합과 함께 스프링 부트 프로젝트가 있고 API를 문서화하려고합니다. 내 POM 파일에 다음 종속성 설정이 있습니다. 나는이 시점에서 내가 할 수 있어야한다고 여기 다른 답변을 몇 읽는에서 수집 한 바로는Spring 부트 Swagger REST API 문서

 @Configuration 
     @EnableSwagger2 
public class SwaggerConfig { 

    @Bean 
    public Docket api(){ 
     return new Docket(DocumentationType.SWAGGER_2) 
      .select() 
      .apis(RequestHandlerSelectors.any()) 
      .paths(PathSelectors.regex("/api/.*")) 
      .build() 
      .apiInfo(apiInfo()); 
    } 

    private ApiInfo apiInfo() { 
     return new ApiInfoBuilder() 
      .title("My application title") 
      .description("This is a test of documenting EST API's") 
      .version("V1.2") 
      .termsOfServiceUrl("http://terms-of-services.url") 
      .license("LICENSE") 
      .licenseUrl("http://url-to-license.com") 
      .build(); 
    } 

} 

:

<dependency> 
     <groupId>io.springfox</groupId> 
     <artifactId>springfox-swagger-ui</artifactId> 
     <version>2.4.0</version> 
    </dependency> 
    <dependency> 
     <groupId>io.springfox</groupId> 
     <artifactId>springfox-swagger2</artifactId> 
     <version>2.5.0</version> 
    </dependency> 

이것은 EnableSwagger2 @Configuration와 @ 내 자신감 구성 클래스입니다 http://myapp/v2/api-docs 또는 그 대신에 http://localhost:8080/myapp/api-docs과 같은 URL의 내용을 참조하십시오. 위의 URL의 "myapp"부분이 본사가 상주하는 클래스의 이름을 참조한다고 가정했습니다 (정확합니까?). 또한 포트 8080과 포트 80을 사용해 보았습니다. 결론은 사이트에 도달 할 수 없다는 것입니다. 나는 대답을 보았다. herehere 그러나 나는 어떤 성공도 보내지 않고있다. 어떤 도움이라도 대단히 감사 할 것입니다, 미리 감사드립니다. 다음 문서에서 볼 수 있듯이

+0

이 시도 될 것입니다 : HTTP : // localhost를 : 8080/myapp/swagger-ui.html –

답변

0

: https://springfox.github.io/springfox/docs/snapshot/#springfox-swagger-ui

엔드 포인트 귀하의 경우에, 자신감 - ui.html 지금, 그것은 http://localhost:8080/myapp/swagger-ui.html

+0

추가 질문, URL의 "myapp"부분은 내 "main"이 상주하는 클래스의 이름입니까? – TKPhillyBurb

+0

netstat을 볼 때 포트 8080이 사용되는 것을보고 있지 않습니다. – TKPhillyBurb

+0

http://stackoverflow.com/questions/24452072/how-do-i-choose-the-url-for-my-spring-boot-webapp – fbak