Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
a0f78a36
Commit
a0f78a36
authored
May 24, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重新整理配置结构
parent
ae2c4080
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
56 deletions
+61
-56
src/main/java/com/stylefeng/guns/config/EhCacheConfig.java
+5
-53
src/main/java/com/stylefeng/guns/config/MybatisPlusConfig.java
+0
-3
src/main/java/com/stylefeng/guns/config/web/WebConfig.java
+56
-0
No files found.
src/main/java/com/stylefeng/guns/config/
OtherConfigs
.java
→
src/main/java/com/stylefeng/guns/config/
EhCacheConfig
.java
View file @
a0f78a36
package
com
.
stylefeng
.
guns
.
config
;
package
com
.
stylefeng
.
guns
.
config
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.alibaba.druid.support.spring.stat.BeanTypeAutoProxyCreator
;
import
com.alibaba.druid.support.spring.stat.DruidStatInterceptor
;
import
com.google.code.kaptcha.impl.DefaultKaptcha
;
import
com.google.code.kaptcha.util.Config
;
import
com.stylefeng.guns.core.intercept.SessionInterceptor
;
import
net.sf.ehcache.CacheManager
;
import
net.sf.ehcache.CacheManager
;
import
org.springframework.cache.ehcache.EhCacheCacheManager
;
import
org.springframework.cache.ehcache.EhCacheCacheManager
;
import
org.springframework.cache.ehcache.EhCacheManagerFactoryBean
;
import
org.springframework.cache.ehcache.EhCacheManagerFactoryBean
;
...
@@ -13,8 +7,6 @@ import org.springframework.context.annotation.Bean;
...
@@ -13,8 +7,6 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.ClassPathResource
;
import
java.util.Properties
;
/**
/**
* 其他bean的配置
* 其他bean的配置
*
*
...
@@ -22,7 +14,7 @@ import java.util.Properties;
...
@@ -22,7 +14,7 @@ import java.util.Properties;
* @date 2017-05-20 23:11
* @date 2017-05-20 23:11
*/
*/
@Configuration
@Configuration
public
class
OtherConfigs
{
public
class
EhCacheConfig
{
/**
/**
* EhCache的配置
* EhCache的配置
...
@@ -31,54 +23,14 @@ public class OtherConfigs {
...
@@ -31,54 +23,14 @@ public class OtherConfigs {
public
EhCacheCacheManager
cacheManager
(
CacheManager
cacheManager
)
{
public
EhCacheCacheManager
cacheManager
(
CacheManager
cacheManager
)
{
return
new
EhCacheCacheManager
(
cacheManager
);
return
new
EhCacheCacheManager
(
cacheManager
);
}
}
/**
* EhCache的配置
*/
@Bean
@Bean
public
EhCacheManagerFactoryBean
ehcache
()
{
public
EhCacheManagerFactoryBean
ehcache
()
{
EhCacheManagerFactoryBean
ehCacheManagerFactoryBean
=
new
EhCacheManagerFactoryBean
();
EhCacheManagerFactoryBean
ehCacheManagerFactoryBean
=
new
EhCacheManagerFactoryBean
();
ehCacheManagerFactoryBean
.
setConfigLocation
(
new
ClassPathResource
(
"ehcache.xml"
));
ehCacheManagerFactoryBean
.
setConfigLocation
(
new
ClassPathResource
(
"ehcache.xml"
));
return
ehCacheManagerFactoryBean
;
return
ehCacheManagerFactoryBean
;
}
}
/**
* 验证码生成相关
*/
@Bean
public
DefaultKaptcha
kaptcha
()
{
Properties
properties
=
new
Properties
();
properties
.
put
(
"kaptcha.border"
,
"no"
);
properties
.
put
(
"kaptcha.border.color"
,
"105,179,90"
);
properties
.
put
(
"kaptcha.textproducer.font.color"
,
"blue"
);
properties
.
put
(
"kaptcha.image.width"
,
"125"
);
properties
.
put
(
"kaptcha.image.height"
,
"45"
);
properties
.
put
(
"kaptcha.textproducer.font.size"
,
"45"
);
properties
.
put
(
"kaptcha.session.key"
,
"code"
);
properties
.
put
(
"kaptcha.textproducer.char.length"
,
"4"
);
properties
.
put
(
"kaptcha.textproducer.font.names"
,
"宋体,楷体,微软雅黑"
);
Config
config
=
new
Config
(
properties
);
DefaultKaptcha
defaultKaptcha
=
new
DefaultKaptcha
();
defaultKaptcha
.
setConfig
(
config
);
return
defaultKaptcha
;
}
/**
* session的拦截器,用在非controller层调用session
*/
@Bean
public
SessionInterceptor
sessionInterceptor
()
{
return
new
SessionInterceptor
();
}
/**
* druid数据库连接池监控
*/
@Bean
public
DruidStatInterceptor
druidStatInterceptor
()
{
return
new
DruidStatInterceptor
();
}
@Bean
public
BeanTypeAutoProxyCreator
beanTypeAutoProxyCreator
()
{
BeanTypeAutoProxyCreator
beanTypeAutoProxyCreator
=
new
BeanTypeAutoProxyCreator
();
beanTypeAutoProxyCreator
.
setTargetBeanType
(
DruidDataSource
.
class
);
beanTypeAutoProxyCreator
.
setInterceptorNames
(
"druidStatInterceptor"
);
return
beanTypeAutoProxyCreator
;
}
}
}
src/main/java/com/stylefeng/guns/config/MybatisPlusConfig.java
View file @
a0f78a36
...
@@ -20,9 +20,6 @@ import org.springframework.context.annotation.Configuration;
...
@@ -20,9 +20,6 @@ import org.springframework.context.annotation.Configuration;
public
class
MybatisPlusConfig
{
public
class
MybatisPlusConfig
{
@Autowired
@Autowired
DruidProperties
databaseProperties
;
@Autowired
DruidProperties
druidProperties
;
DruidProperties
druidProperties
;
/**
/**
...
...
src/main/java/com/stylefeng/guns/config/web/WebConfig.java
View file @
a0f78a36
package
com
.
stylefeng
.
guns
.
config
.
web
;
package
com
.
stylefeng
.
guns
.
config
.
web
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.alibaba.druid.support.http.StatViewServlet
;
import
com.alibaba.druid.support.http.StatViewServlet
;
import
com.alibaba.druid.support.spring.stat.BeanTypeAutoProxyCreator
;
import
com.alibaba.druid.support.spring.stat.DruidStatInterceptor
;
import
com.google.code.kaptcha.impl.DefaultKaptcha
;
import
com.google.code.kaptcha.util.Config
;
import
com.stylefeng.guns.core.intercept.SessionInterceptor
;
import
com.stylefeng.guns.core.listener.ConfigListener
;
import
com.stylefeng.guns.core.listener.ConfigListener
;
import
com.stylefeng.guns.core.util.xss.XssFilter
;
import
com.stylefeng.guns.core.util.xss.XssFilter
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
...
@@ -10,6 +16,8 @@ import org.springframework.context.annotation.Bean;
...
@@ -10,6 +16,8 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.context.request.RequestContextListener
;
import
org.springframework.web.context.request.RequestContextListener
;
import
java.util.Properties
;
/**
/**
* web 配置类
* web 配置类
*
*
...
@@ -30,6 +38,25 @@ public class WebConfig {
...
@@ -30,6 +38,25 @@ public class WebConfig {
}
}
/**
/**
* druid数据库连接池监控
*/
@Bean
public
DruidStatInterceptor
druidStatInterceptor
()
{
return
new
DruidStatInterceptor
();
}
/**
* druid数据库连接池监控
*/
@Bean
public
BeanTypeAutoProxyCreator
beanTypeAutoProxyCreator
()
{
BeanTypeAutoProxyCreator
beanTypeAutoProxyCreator
=
new
BeanTypeAutoProxyCreator
();
beanTypeAutoProxyCreator
.
setTargetBeanType
(
DruidDataSource
.
class
);
beanTypeAutoProxyCreator
.
setInterceptorNames
(
"druidStatInterceptor"
);
return
beanTypeAutoProxyCreator
;
}
/**
* xssFilter注册
* xssFilter注册
*/
*/
@Bean
@Bean
...
@@ -54,4 +81,33 @@ public class WebConfig {
...
@@ -54,4 +81,33 @@ public class WebConfig {
public
ServletListenerRegistrationBean
<
ConfigListener
>
configListenerRegistration
()
{
public
ServletListenerRegistrationBean
<
ConfigListener
>
configListenerRegistration
()
{
return
new
ServletListenerRegistrationBean
<>(
new
ConfigListener
());
return
new
ServletListenerRegistrationBean
<>(
new
ConfigListener
());
}
}
/**
* session的拦截器,用在非controller层调用session
*/
@Bean
public
SessionInterceptor
sessionInterceptor
()
{
return
new
SessionInterceptor
();
}
/**
* 验证码生成相关
*/
@Bean
public
DefaultKaptcha
kaptcha
()
{
Properties
properties
=
new
Properties
();
properties
.
put
(
"kaptcha.border"
,
"no"
);
properties
.
put
(
"kaptcha.border.color"
,
"105,179,90"
);
properties
.
put
(
"kaptcha.textproducer.font.color"
,
"blue"
);
properties
.
put
(
"kaptcha.image.width"
,
"125"
);
properties
.
put
(
"kaptcha.image.height"
,
"45"
);
properties
.
put
(
"kaptcha.textproducer.font.size"
,
"45"
);
properties
.
put
(
"kaptcha.session.key"
,
"code"
);
properties
.
put
(
"kaptcha.textproducer.char.length"
,
"4"
);
properties
.
put
(
"kaptcha.textproducer.font.names"
,
"宋体,楷体,微软雅黑"
);
Config
config
=
new
Config
(
properties
);
DefaultKaptcha
defaultKaptcha
=
new
DefaultKaptcha
();
defaultKaptcha
.
setConfig
(
config
);
return
defaultKaptcha
;
}
}
}
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