SpringBoot集成Swagger

简介

详见 SpringMVC集成Swagger

配置

Maven 配置

 
        UTF-8
        UTF-8
        1.8
        2.2.2
    

 
        
            org.springframework.boot
            spring-boot-starter-web
        
        
        
            io.springfox
            springfox-swagger2
            ${springfox.version}
        
        
            io.springfox
            springfox-swagger-ui
            ${springfox.version}
        
  

Application配置

@MapperScan("com.anotherme17.anothernote.mapper")
@SpringBootApplication
@EnableSwagger2
public class AnothernoteApplication {

    /*Swagger*/
    @Bean
    public Docket swaggerSpringMvcPlugin() {
        ApiInfo apiInfo = new ApiInfo("A...", "=  =", "1.0.0",
                "", "...", null, null);
        Docket docket = new Docket(DocumentationType.SWAGGER_2).select().paths(regex("/v1/*/.*")).build()
                .apiInfo(apiInfo).useDefaultResponseMessages(false);
        return docket;
    }

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

配置完成

访问接口 http://[服务器IP]:[端口号]/[项目名]/swagger-ui.html

你可能感兴趣的:(SpringBoot集成Swagger)