2017-09-13 3 views
0

ich versuche api Dokumentation mit swagger2 und springfox zu implementieren. Mein Projekt ist kein Spring Boot oder Maven, es hängt von XML-Dateien ab.Prahlerei 2 Dokumentation arbeiten nicht

Ich habe die Klasse hinzugefügt:

SwaggerConfig

import org.springframework.context.annotation.Bean; 
import org.springframework.context.annotation.ComponentScan; 
import org.springframework.context.annotation.Configuration; 
import org.springframework.context.annotation.PropertySource; 
import springfox.documentation.builders.ApiInfoBuilder; 
import springfox.documentation.builders.PathSelectors; 
import springfox.documentation.service.ApiInfo; 
import springfox.documentation.spi.DocumentationType; 
import springfox.documentation.spring.web.plugins.Docket; 
import springfox.documentation.swagger2.annotations.EnableSwagger2; 



@EnableSwagger2 
@PropertySource("classpath:swagger.properties") 
@ComponentScan(basePackageClasses = ProductController.class) 
@Configuration 
public class SwaggerConfig { 

    private static final String SWAGGER_API_VERSION = "1.0"; 
    private static final String LICENSE_TEXT = "License"; 
    private static final String title = "Products REST API"; 
    private static final String description = "RESTful API for Products"; 

    private ApiInfo apiInfo() { 
     return new ApiInfoBuilder() 
       .title(title) 
       .description(description) 
       .license(LICENSE_TEXT) 
       .version(SWAGGER_API_VERSION) 
       .build(); 
    } 

    @Bean 
    public Docket productsApi() { 
     return new Docket(DocumentationType.SWAGGER_2) 
       .apiInfo(apiInfo()) 
       .pathMapping("/") 
       .select() 
       .paths(PathSelectors.regex("/*")) 
       .build(); 
    } 


} 

so, wenn ich laufen die Tomcatbediener es normalerweise ohne Fehler ausgeführt, aber wenn ich fügen Sie den folgenden Link:

http://localhost:8080/swagger-ui.html

nichts passiert. Fehle ich etwas Konfiguration oder irgendeinen Vorschlag bitte?

Vielen Dank im Voraus.

+0

haben Sie UiConfiguration Bean zu definieren versucht? –

+0

@DmitrySenkovich Vielen Dank für Ihre Antwort, aber ich habe es geschafft, das Problem zu lösen, und ich werde die Lösung posten. – Elias

Antwort

0

Problem wird nach der Zugabe, diese Aussagen in meiner

feder config.xml

gelöst
<mvc:default-servlet-handler/> 
     <mvc:annotation-driven/> 
     <mvc:resources location="classpath:/META-INF/resources/" mapping="swagger-ui.html"></mvc:resources> 
     <mvc:resources location="classpath:/META-INF/resources/webjars/" mapping="/webjars/**"></mvc:resources> 
     <bean class="springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration" id="swagger2Config"/> 
Verwandte Themen