idea SpringBoot项目 swagger测试

1.pom.xml文件中引入依赖


   io.springfox
   springfox-swagger2
   2.6.1



   io.springfox
   springfox-swagger-ui
   2.6.1

2.Application启动类

package com.springdir.springdir;

import com.springdir.springdir.SpringdirApplication;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2
@SpringBootApplication
@EnableAutoConfiguration
public class Application extends SpringBootServletInitializer{

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
    public static void main(String[] args) {
        SpringApplication.run(SpringdirApplication.class);
    }
}

idea SpringBoot项目 swagger测试_第1张图片
访问地址: http://localhost:8086/swagger-ui.html#/
idea SpringBoot项目 swagger测试_第2张图片

你可能感兴趣的:(Spring,Boot,swagger,spring-boot)