Added Springfox Swagger-UI and it's not working, what am I missing?

后端 未结 11 1510
甜味超标
甜味超标 2020-12-02 00:00

Following the instructions here:

http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api

I added these dependencies to my project:



        
11条回答
  •  臣服心动
    2020-12-02 00:35

    For Spring Version >= 2.2, you should add the dependency springfox-boot-starter

    pom.xml:

    
        1.8
        3.0.0
    
    
    
        
            io.springfox
            springfox-swagger2
            ${io.springfox.version}
        
        
            io.springfox
            springfox-swagger-ui
            ${io.springfox.version}
        
        
            io.springfox
            springfox-data-rest
            ${io.springfox.version}
        
        
            io.springfox
            springfox-bean-validators
            ${io.springfox.version}
        
        
            io.springfox
            springfox-boot-starter
            ${io.springfox.version}
        
    
    

    ApplicationSwaggerConfig

    @Configuration
    @EnableSwagger2
    public class ApplicationSwaggerConfig {
    
        @Bean
        public Docket employeeApi() {
            return new Docket(DocumentationType.SWAGGER_2)
                    .select()
                    .apis(RequestHandlerSelectors.any())
                    .paths(PathSelectors.any())
                    .build();
        }
    
    }
    

    Swagger-UI link: http://localhost:8080/swagger-ui/index.html#/

提交回复
热议问题