Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
shop
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
shop
Commits
bcce0ba7
Commit
bcce0ba7
authored
Sep 19, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
a36ea402
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
5 deletions
+26
-5
DruidConfig.java
src/main/java/com/egolm/shop/config/DruidConfig.java
+26
-5
No files found.
src/main/java/com/egolm/shop/config/DruidConfig.java
View file @
bcce0ba7
...
...
@@ -15,12 +15,15 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean;
import
org.springframework.boot.web.servlet.ServletRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.DependsOn
;
import
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
;
import
com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties
;
import
com.alibaba.druid.support.http.StatViewServlet
;
import
com.alibaba.druid.support.http.WebStatFilter
;
import
com.alibaba.druid.util.Utils
;
import
com.alibaba.druid.wall.WallConfig
;
import
com.alibaba.druid.wall.WallFilter
;
@Configuration
@ConditionalOnWebApplication
...
...
@@ -36,7 +39,8 @@ public class DruidConfig {
final
String
filePath
=
"support/http/resources/js/common.js"
;
Filter
filter
=
new
Filter
()
{
@Override
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
public
void
doFilter
(
ServletRequest
request
,
ServletResponse
response
,
FilterChain
chain
)
throws
IOException
,
ServletException
{
chain
.
doFilter
(
request
,
response
);
response
.
resetBuffer
();
String
text
=
Utils
.
readFromResource
(
filePath
);
...
...
@@ -50,22 +54,39 @@ public class DruidConfig {
registrationBean
.
addUrlPatterns
(
commonJsPattern
);
return
registrationBean
;
}
@Bean
public
FilterRegistrationBean
<
Filter
>
webStatFilterRegistrationBean
(
DruidStatProperties
properties
)
{
WebStatFilter
filter
=
new
WebStatFilter
();
FilterRegistrationBean
<
Filter
>
registrationBean
=
new
FilterRegistrationBean
<
Filter
>();
registrationBean
.
setFilter
(
filter
);
registrationBean
.
addUrlPatterns
(
"/*"
);
registrationBean
.
addInitParameter
(
"exclusions"
,
"*.js, *.gif, *.jpg, *.bmp, *.png, *.css, *.ico, /v2/api-docs, /swagger*, /webjars/*, /druid/*"
);
registrationBean
.
addInitParameter
(
"exclusions"
,
"*.js, *.gif, *.jpg, *.bmp, *.png, *.css, *.ico, /v2/api-docs, /swagger*, /webjars/*, /druid/*"
);
return
registrationBean
;
}
@Bean
public
ServletRegistrationBean
<?>
setvletRegistrationBean
()
{
ServletRegistrationBean
<
StatViewServlet
>
setvletRegistrationBean
=
new
ServletRegistrationBean
<
StatViewServlet
>(
new
StatViewServlet
(),
"/druid/*"
);
ServletRegistrationBean
<
StatViewServlet
>
setvletRegistrationBean
=
new
ServletRegistrationBean
<
StatViewServlet
>(
new
StatViewServlet
(),
"/druid/*"
);
setvletRegistrationBean
.
addInitParameter
(
"resetEnable"
,
"true"
);
return
setvletRegistrationBean
;
}
@Bean
(
name
=
"wallConfig"
)
WallConfig
wallFilterConfig
()
{
WallConfig
wc
=
new
WallConfig
();
wc
.
setMultiStatementAllow
(
true
);
return
wc
;
}
@Bean
(
name
=
"wallConfig"
)
@DependsOn
(
"wallConfig"
)
WallFilter
wallFilter
(
WallConfig
wallConfig
){
WallFilter
wfilter
=
new
WallFilter
();
wfilter
.
setConfig
(
wallConfig
);
return
wfilter
;
}
}
Write
Preview
Markdown
is supported
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