java spring配置swagger

2020-08-21  本文已影响0人  愤怒的哪吒

1、pom.xml导入包

<!--swagger-->

<dependency>

    <groupId>com.didispace

    <artifactId>spring-boot-starter-swagger

    <version>1.1.0.RELEASE

</dependency>

2、WebMvcConfig配置

@Configuration

public class WebMvcConfigextends WebMvcConfigurationSupport {

@Override

    public void addResourceHandlers(ResourceHandlerRegistry registry) {

registry.addResourceHandler("swagger-ui.html")

.addResourceLocations("classpath:/META-INF/resources/");

        registry.addResourceHandler("/webjars/**")

.addResourceLocations("classpath:/META-INF/resources/webjars/");

    }

}

3、application 配置 

开启swagger

4、application.yml 配置

5、使用

上一篇下一篇

猜你喜欢

热点阅读