Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
197213e9
Commit
197213e9
authored
Oct 31, 2020
by
季圣华
Browse files
集成swagger
parent
47fbbf40
Changes
3
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
197213e9
...
...
@@ -87,6 +87,17 @@
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
3.0.7.1
</version>
</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>
<build>
...
...
src/main/java/com/jsh/erp/config/Swagger2Config.java
0 → 100644
View file @
197213e9
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
();
}
}
src/main/java/com/jsh/erp/filter/LogCostFilter.java
View file @
197213e9
...
...
@@ -15,7 +15,7 @@ import java.util.regex.Pattern;
@WebFilter
(
filterName
=
"LogCostFilter"
,
urlPatterns
=
{
"/*"
},
initParams
=
{
@WebInitParam
(
name
=
"ignoredUrl"
,
value
=
".css#.js#.jpg#.png#.gif#.ico"
),
@WebInitParam
(
name
=
"filterPath"
,
value
=
"/user/login#/user/registerUser"
)})
value
=
"/user/login#/user/registerUser
#/v2/api-docs
"
)})
public
class
LogCostFilter
implements
Filter
{
private
static
final
String
FILTER_PATH
=
"filterPath"
;
...
...
@@ -52,7 +52,8 @@ public class LogCostFilter implements Filter {
chain
.
doFilter
(
request
,
response
);
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
);
return
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment