集成swagger
This commit is contained in:
11
pom.xml
11
pom.xml
@@ -87,6 +87,17 @@
|
|||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
<version>3.0.7.1</version>
|
<version>3.0.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>2.7.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||||
|
<version>1.6</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
44
src/main/java/com/jsh/erp/config/Swagger2Config.java
Normal file
44
src/main/java/com/jsh/erp/config/Swagger2Config.java
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package com.jsh.erp.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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插件集成配置
|
||||||
|
*
|
||||||
|
* @author jishenghua
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
|
public class Swagger2Config {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Docket createRestApi() {
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.apiInfo(this.apiInfo())
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.any())
|
||||||
|
.paths(PathSelectors.any())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiInfo apiInfo() {
|
||||||
|
return new ApiInfoBuilder()
|
||||||
|
.title("Mybatis-Plus Plugin Example RESTful APIs")
|
||||||
|
.description("集成Mybatis-Plus模块接口描述")
|
||||||
|
.termsOfServiceUrl("http://127.0.0.1")
|
||||||
|
.contact(new Contact("jishenghua", "", ""))
|
||||||
|
.version("2.1.1")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ import java.util.regex.Pattern;
|
|||||||
@WebFilter(filterName = "LogCostFilter", urlPatterns = {"/*"},
|
@WebFilter(filterName = "LogCostFilter", urlPatterns = {"/*"},
|
||||||
initParams = {@WebInitParam(name = "ignoredUrl", value = ".css#.js#.jpg#.png#.gif#.ico"),
|
initParams = {@WebInitParam(name = "ignoredUrl", value = ".css#.js#.jpg#.png#.gif#.ico"),
|
||||||
@WebInitParam(name = "filterPath",
|
@WebInitParam(name = "filterPath",
|
||||||
value = "/user/login#/user/registerUser")})
|
value = "/user/login#/user/registerUser#/v2/api-docs")})
|
||||||
public class LogCostFilter implements Filter {
|
public class LogCostFilter implements Filter {
|
||||||
|
|
||||||
private static final String FILTER_PATH = "filterPath";
|
private static final String FILTER_PATH = "filterPath";
|
||||||
@@ -52,7 +52,8 @@ public class LogCostFilter implements Filter {
|
|||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (requestUrl != null && (requestUrl.contains("/login.html") || requestUrl.contains("/register.html"))) {
|
if (requestUrl != null && (requestUrl.contains("/doc.html") ||
|
||||||
|
requestUrl.contains("/register.html") || requestUrl.contains("/login.html"))) {
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user