增加swagger接口

dep_wangsr
yangzhengze 7 years ago committed by Limy
parent 7ceb15ca33
commit 79a577836a

@ -38,6 +38,7 @@
<velocity.version>1.7</velocity.version>
<quartz.version>2.3.0</quartz.version>
<kaptcha.version>2.3.2</kaptcha.version>
<swagger.version>2.7.0</swagger.version>
</properties>
<dependencies>
@ -216,6 +217,20 @@
</exclusions>
</dependency>
<!-- swagger2-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<!-- swagger2-UI-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
</dependencies>
<build>

@ -37,5 +37,9 @@ public class ResourcesConfig extends WebMvcConfigurerAdapter
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
registry.addResourceHandler("/profile/**").addResourceLocations("file:" + RuoYiConfig.getProfile());
/**swagger配置*/
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}

@ -0,0 +1,41 @@
package com.ruoyi.framework.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* Swagger2
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
//.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.*.*.controller"))
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("系统接口列表")
.description("API接口测试平台\",\n" +
" \"提供后台所有Restful接口\",")
.termsOfServiceUrl("http://localhost/swagger-ui.html")
.contact(new Contact("RuoYi", "https://gitee.com/y_project/RuoYi", "1403014932@qq.com"))
.version("1.1.0")
.build();
}
}
Loading…
Cancel
Save