2017-05-19 2 views
0

Dies ist meine Konfigurationsklassekann nicht Swagger UI mit Federverschluß

@SpringBootApplication 
@EnableJpaRepositories 
@EnableTransactionManagement 
@EnableSwagger2 
public class SwaggerExampleApplication { 

public static void main(String[] args) { 
    SpringApplication.run(SwaggerExampleApplication.class, args); 
} 

@Bean 
    public Docket productApi() { 
     return new Docket(DocumentationType.SWAGGER_2) 
       .select().apis(RequestHandlerSelectors.basePackage("com.example.controller")).paths(PathSelectors.any()).build().pathMapping("/"); 
    } 

private ApiInfo apiInfo() { 
     return new ApiInfoBuilder() 
     .title("Simple Hello App") 
     .description("A simple calculator REST service made with Spring Boot in Java") 
     .contact("lavya") 
     .version("1.0") 
     .build(); 
    } 

}

Dies ist meine Ressourcenklasse

@Component 
@Path("/hello") 
@Api(value="Test Hello",description="testing swagger") 
public class ResourceController { 

@GET 
@Produces({MediaType.APPLICATION_JSON}) 
@ApiOperation(value="list employess",notes="list employees") 
public List<Employee> displayDetails(){ 
    System.out.println("inside display"); 
    return Arrays.asList(new Employee(1,"ab","cdd","sass")); 
    } 

iam nicht in der Lage retrive Prahlerei ui, http://localhost:8080/swagger-ui.html auf Laufen bringen die App, kann jemand sagen warum?

+0

Was passiert, wenn Sie die obige Swagger-URL erreichen? – pvpkiran

+0

Ich bekomme HTTP 404 Fehler, Seite nicht gefunden – Laya

+0

Sind Sie sicher, dass Ihre Anwendung auf 8080 läuft? – pvpkiran

Antwort

-1

Versuchen Sie dies. Für mich geht das.

@Configuration 
public class WebMvcConfiguration extends WebMvcConfigurationSupport { 

    @Override 
    public void addResourceHandlers(final ResourceHandlerRegistry registry) { 
     // Make Swagger meta-data available via <baseURL>/v2/api-docs/ 
     registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); 
     // Make Swagger UI available via <baseURL>/swagger-ui.html 
     registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); 
    } 
} 
+0

Brauchen wir diese Konfiguration im Falle eines Federstarts? , – Laya