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
316885a3
Commit
316885a3
authored
May 21, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
主页显示问题解决
parent
3ecf4215
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
295 additions
and
232 deletions
+295
-232
src/main/java/com/stylefeng/guns/GunsApplication.java
+1
-1
src/main/java/com/stylefeng/guns/config/ControllerAopConfig.java
+24
-0
src/main/java/com/stylefeng/guns/config/EhcacheConfig.java
+0
-32
src/main/java/com/stylefeng/guns/config/KaptchaConfig.java
+0
-36
src/main/java/com/stylefeng/guns/config/OtherConfigs.java
+69
-0
src/main/java/com/stylefeng/guns/config/ShiroConfig.java
+0
-16
src/main/java/com/stylefeng/guns/config/SpringMvcConfig.java
+38
-0
src/main/java/com/stylefeng/guns/modular/system/controller/LogController.java
+1
-1
src/main/java/project/config/web/ControllerAopConfig.java
+26
-26
src/main/java/project/config/web/SpringMvcConfig.java
+119
-119
src/main/resources/ehcache.xml
+17
-1
No files found.
src/main/java/com/stylefeng/guns/GunsApplication.java
View file @
316885a3
...
...
@@ -13,6 +13,6 @@ public class GunsApplication {
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
GunsApplication
.
class
,
args
);
logger
.
info
(
"
Portal
Application is sussess!"
);
logger
.
info
(
"
Guns
Application is sussess!"
);
}
}
src/main/java/com/stylefeng/guns/config/ControllerAopConfig.java
0 → 100644
View file @
316885a3
package
com
.
stylefeng
.
guns
.
config
;
import
com.stylefeng.guns.core.intercept.SessionInterceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* 保留类,如果控制器需要些aop在这里写
*
* @author fengshuonan
* @date 2016年11月12日 下午4:48:10
*/
@Configuration
public
class
ControllerAopConfig
{
/**
* session的拦截器,用在非controller层调用session
*/
@Bean
public
SessionInterceptor
sessionInterceptor
()
{
return
new
SessionInterceptor
();
}
}
src/main/java/com/stylefeng/guns/config/EhcacheConfig.java
deleted
100644 → 0
View file @
3ecf4215
package
com
.
stylefeng
.
guns
.
config
;
import
net.sf.ehcache.CacheManager
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cache.ehcache.EhCacheCacheManager
;
import
org.springframework.cache.ehcache.EhCacheManagerFactoryBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.io.ClassPathResource
;
/**
* ehcache缓存的配置
*
* @author fengshuonan
* @date 2017-04-24 20:41
*/
@Configuration
@EnableCaching
public
class
EhcacheConfig
{
@Bean
public
EhCacheCacheManager
cacheManager
(
CacheManager
cacheManager
){
return
new
EhCacheCacheManager
(
cacheManager
);
}
@Bean
public
EhCacheManagerFactoryBean
ehcache
(){
EhCacheManagerFactoryBean
ehCacheManagerFactoryBean
=
new
EhCacheManagerFactoryBean
();
ehCacheManagerFactoryBean
.
setConfigLocation
(
new
ClassPathResource
(
"ehcache.xml"
));
return
ehCacheManagerFactoryBean
;
}
}
src/main/java/com/stylefeng/guns/config/KaptchaConfig.java
deleted
100644 → 0
View file @
3ecf4215
package
com
.
stylefeng
.
guns
.
config
;
import
com.google.code.kaptcha.impl.DefaultKaptcha
;
import
com.google.code.kaptcha.util.Config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.Properties
;
/**
* 验证码生成的配置
*
* @author fengshuonan
* @date 2017-05-20 22:03
*/
@Configuration
public
class
KaptchaConfig
{
@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
;
}
}
src/main/java/com/stylefeng/guns/config/OtherConfigs.java
0 → 100644
View file @
316885a3
package
com
.
stylefeng
.
guns
.
config
;
import
com.google.code.kaptcha.impl.DefaultKaptcha
;
import
com.google.code.kaptcha.util.Config
;
import
net.sf.ehcache.CacheManager
;
import
org.springframework.cache.ehcache.EhCacheCacheManager
;
import
org.springframework.cache.ehcache.EhCacheManagerFactoryBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.io.ClassPathResource
;
import
project.config.web.beetl.BeetlConfiguration
;
import
java.util.Properties
;
/**
* 其他bean的配置
*
* @author fengshuonan
* @date 2017-05-20 23:11
*/
@Configuration
public
class
OtherConfigs
{
/**
* EhCache的配置
*/
@Bean
public
EhCacheCacheManager
cacheManager
(
CacheManager
cacheManager
)
{
return
new
EhCacheCacheManager
(
cacheManager
);
}
@Bean
public
EhCacheManagerFactoryBean
ehcache
()
{
EhCacheManagerFactoryBean
ehCacheManagerFactoryBean
=
new
EhCacheManagerFactoryBean
();
ehCacheManagerFactoryBean
.
setConfigLocation
(
new
ClassPathResource
(
"ehcache.xml"
));
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
;
}
/**
* beetl的配置
*/
@Bean
(
initMethod
=
"init"
)
public
BeetlConfiguration
beetlConfiguration
()
{
BeetlConfiguration
beetlConfiguration
=
new
BeetlConfiguration
();
beetlConfiguration
.
setConfigFileResource
(
new
ClassPathResource
(
"beetl.properties"
));
return
beetlConfiguration
;
}
}
src/main/java/com/stylefeng/guns/config/ShiroConfig.java
View file @
316885a3
...
...
@@ -38,9 +38,6 @@ public class ShiroConfig {
//设置自定义Realm
securityManager
.
setRealm
(
this
.
shiroDbRealm
());
//将缓存管理器,交给安全管理器
// securityManager.setCacheManager(this.shiroEhcacheManager());
//记住密码管理
securityManager
.
setRememberMeManager
(
rememberMeManager
);
return
securityManager
;
...
...
@@ -122,19 +119,6 @@ public class ShiroConfig {
}
/**
* 用户授权信息Cache, 采用EhCache
*
* @author fengshuonan
*/
// @Bean
// public EhCacheManager shiroEhcacheManager(){
// EhCacheManager ehCacheManager = new EhCacheManager();
// ehCacheManager.setCacheManagerConfigFile("classpath:ehcache.xml");
// ehCacheManager.setCacheManager(CacheManager.create());
// return ehCacheManager;
// }
/**
* 在方法中 注入 securityManager,进行代理控制
*
* @author fengshuonan
...
...
src/main/java/com/stylefeng/guns/config/SpringMvcConfig.java
0 → 100644
View file @
316885a3
package
com
.
stylefeng
.
guns
.
config
;
import
org.beetl.ext.spring.BeetlSpringViewResolver
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.EnableAspectJAutoProxy
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
project.config.web.beetl.BeetlConfiguration
;
/**
* spring mvc配置类
*
* @author fengshuonan
* @date 2016年11月12日 下午5:03:32
*/
@Configuration
public
class
SpringMvcConfig
extends
WebMvcConfigurerAdapter
{
// beetl的配置
@Bean
(
initMethod
=
"init"
)
public
BeetlConfiguration
beetlConfiguration
()
{
BeetlConfiguration
beetlConfiguration
=
new
BeetlConfiguration
();
beetlConfiguration
.
setConfigFileResource
(
new
ClassPathResource
(
"beetl.properties"
));
return
beetlConfiguration
;
}
// beetl的视图解析器
@Bean
public
BeetlSpringViewResolver
beetlViewResolver
()
{
BeetlSpringViewResolver
beetlSpringViewResolver
=
new
BeetlSpringViewResolver
();
beetlSpringViewResolver
.
setConfig
(
beetlConfiguration
());
beetlSpringViewResolver
.
setContentType
(
"text/html;charset=UTF-8"
);
beetlSpringViewResolver
.
setOrder
(
0
);
return
beetlSpringViewResolver
;
}
}
src/main/java/com/stylefeng/guns/modular/system/controller/LogController.java
View file @
316885a3
...
...
@@ -44,7 +44,7 @@ public class LogController extends BaseController {
/**
* 跳转到日志管理的首页
*/
@RequestMapping
(
""
)
@RequestMapping
(
"
/
"
)
public
String
index
()
{
return
PREFIX
+
"log.html"
;
}
...
...
src/main/java/project/config/web/ControllerAopConfig.java
View file @
316885a3
//
package project.config.web;
//
//
import com.stylefeng.guns.core.intercept.SessionInterceptor;
//
import org.springframework.context.annotation.Bean;
//
import org.springframework.context.annotation.Configuration;
//
import org.springframework.context.annotation.EnableAspectJAutoProxy;
//
/
//
**
//
* 保留类,如果控制器需要些aop在这里写
//
*
//
* @author fengshuonan
//
* @date 2016年11月12日 下午4:48:10
//
*/
//
@Configuration
//
@EnableAspectJAutoProxy
//
public class ControllerAopConfig {
//
//
/**
//
* session的拦截器,用在非controller层调用session
//
*/
//
@Bean
//
public SessionInterceptor sessionInterceptor() {
//
return new SessionInterceptor();
//
}
//
//
}
package
project
.
config
.
web
;
import
com.stylefeng.guns.core.intercept.SessionInterceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.EnableAspectJAutoProxy
;
/**
* 保留类,如果控制器需要些aop在这里写
*
* @author fengshuonan
* @date 2016年11月12日 下午4:48:10
*/
@Configuration
@EnableAspectJAutoProxy
public
class
ControllerAopConfig
{
/**
* session的拦截器,用在非controller层调用session
*/
@Bean
public
SessionInterceptor
sessionInterceptor
()
{
return
new
SessionInterceptor
();
}
}
src/main/java/project/config/web/SpringMvcConfig.java
View file @
316885a3
//
package project.config.web;
//
//
import org.beetl.ext.spring.BeetlSpringViewResolver;
//
import org.hibernate.validator.HibernateValidator;
//
import org.springframework.context.annotation.*;
//
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
//
import org.springframework.core.io.ClassPathResource;
//
import org.springframework.http.MediaType;
//
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
//
import org.springframework.http.converter.StringHttpMessageConverter;
//
import org.springframework.validation.Validator;
//
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
//
import org.springframework.web.multipart.MultipartResolver;
//
import org.springframework.web.multipart.support.StandardServletMultipartResolver;
//
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
//
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
//
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
//
import project.config.web.beetl.BeetlConfiguration;
//
//
import java.nio.charset.Charset;
//
import java.util.ArrayList;
//
import java.util.List;
//
/
//
**
//
* spring mvc配置类
//
*
//
* @author fengshuonan
//
* @date 2016年11月12日 下午5:03:32
//
*/
//
@Configuration
//
@EnableWebMvc
//
@ComponentScan(basePackages = {"com.stylefeng.guns.**.controller", "com.stylefeng.guns.common.controller"})
//
@EnableAspectJAutoProxy
//
@Import({ControllerAopConfig.class})
//
public class SpringMvcConfig extends WebMvcConfigurerAdapter {
//
//
// beetl的配置
//
@Bean(initMethod = "init")
//
public BeetlConfiguration beetlConfiguration() {
//
BeetlConfiguration beetlConfiguration = new BeetlConfiguration();
//
beetlConfiguration.setConfigFileResource(new ClassPathResource("beetl.properties"));
//
return beetlConfiguration;
//
}
//
//
// beetl的视图解析器
//
@Bean
//
public BeetlSpringViewResolver beetlViewResolver() {
//
BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver();
//
beetlSpringViewResolver.setConfig(beetlConfiguration());
//
beetlSpringViewResolver.setContentType("text/html;charset=UTF-8");
//
beetlSpringViewResolver.setOrder(0);
//
return beetlSpringViewResolver;
//
}
//
//
// 配置静态资源的处理,对静态资源的请求转发到servlet容器中默认的servlet上(对静态资源的请求不做处理)
//
@Override
//
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
//
configurer.enable();
//
}
//
//
// 文件上传用的resolver
//
@Bean
//
public MultipartResolver multipartResolver() {
//
return new StandardServletMultipartResolver();
//
}
//
//
// 校验器的配置
//
@Bean
//
public LocalValidatorFactoryBean validator(ReloadableResourceBundleMessageSource messageSource) {
//
LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
//
localValidatorFactoryBean.setProviderClass(HibernateValidator.class);
//
localValidatorFactoryBean.setValidationMessageSource(messageSource);
//
return localValidatorFactoryBean;
//
}
//
//
// 国际化消息资源文件配置(本系统中主要用于显示/错误消息定制)
//
@Bean
//
public ReloadableResourceBundleMessageSource messageSource() {
//
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
//
messageSource.setBasenames("classpath:org/hibernate/validator/ValidationMessages");
//
messageSource.setUseCodeAsDefaultMessage(false);
//
messageSource.setDefaultEncoding("UTF-8");
//
messageSource.setCacheSeconds(60);
//
return messageSource;
//
}
//
//
// 配置全局的验证器实例
//
@Override
//
public Validator getValidator() {
//
return this.validator(messageSource());
//
}
//
//
// 配置spring mvc的拦截器
//
@Override
//
public void addInterceptors(InterceptorRegistry registry) {
//
//
}
//
//
//
//
@Bean
//
public ByteArrayHttpMessageConverter byteMsgConverter() {
//
return new ByteArrayHttpMessageConverter();
//
}
//
//
@Bean
//
public StringHttpMessageConverter stringHttpMessageConverter() {
//
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(
//
Charset.forName("UTF-8"));
//
List<MediaType> list = new ArrayList<MediaType>();
//
list.add(MediaType.TEXT_PLAIN);
//
stringHttpMessageConverter.setSupportedMediaTypes(list);
//
return stringHttpMessageConverter;
//
}
//
//
//
//
}
package
project
.
config
.
web
;
import
org.beetl.ext.spring.BeetlSpringViewResolver
;
import
org.hibernate.validator.HibernateValidator
;
import
org.springframework.context.annotation.*
;
import
org.springframework.context.support.ReloadableResourceBundleMessageSource
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.converter.ByteArrayHttpMessageConverter
;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
org.springframework.validation.Validator
;
import
org.springframework.validation.beanvalidation.LocalValidatorFactoryBean
;
import
org.springframework.web.multipart.MultipartResolver
;
import
org.springframework.web.multipart.support.StandardServletMultipartResolver
;
import
org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
project.config.web.beetl.BeetlConfiguration
;
import
java.nio.charset.Charset
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* spring mvc配置类
*
* @author fengshuonan
* @date 2016年11月12日 下午5:03:32
*/
@Configuration
@EnableWebMvc
@ComponentScan
(
basePackages
=
{
"com.stylefeng.guns.**.controller"
,
"com.stylefeng.guns.common.controller"
})
@EnableAspectJAutoProxy
@Import
({
ControllerAopConfig
.
class
})
public
class
SpringMvcConfig
extends
WebMvcConfigurerAdapter
{
// beetl的配置
@Bean
(
initMethod
=
"init"
)
public
BeetlConfiguration
beetlConfiguration
()
{
BeetlConfiguration
beetlConfiguration
=
new
BeetlConfiguration
();
beetlConfiguration
.
setConfigFileResource
(
new
ClassPathResource
(
"beetl.properties"
));
return
beetlConfiguration
;
}
// beetl的视图解析器
@Bean
public
BeetlSpringViewResolver
beetlViewResolver
()
{
BeetlSpringViewResolver
beetlSpringViewResolver
=
new
BeetlSpringViewResolver
();
beetlSpringViewResolver
.
setConfig
(
beetlConfiguration
());
beetlSpringViewResolver
.
setContentType
(
"text/html;charset=UTF-8"
);
beetlSpringViewResolver
.
setOrder
(
0
);
return
beetlSpringViewResolver
;
}
// 配置静态资源的处理,对静态资源的请求转发到servlet容器中默认的servlet上(对静态资源的请求不做处理)
@Override
public
void
configureDefaultServletHandling
(
DefaultServletHandlerConfigurer
configurer
)
{
configurer
.
enable
();
}
// 文件上传用的resolver
@Bean
public
MultipartResolver
multipartResolver
()
{
return
new
StandardServletMultipartResolver
();
}
// 校验器的配置
@Bean
public
LocalValidatorFactoryBean
validator
(
ReloadableResourceBundleMessageSource
messageSource
)
{
LocalValidatorFactoryBean
localValidatorFactoryBean
=
new
LocalValidatorFactoryBean
();
localValidatorFactoryBean
.
setProviderClass
(
HibernateValidator
.
class
);
localValidatorFactoryBean
.
setValidationMessageSource
(
messageSource
);
return
localValidatorFactoryBean
;
}
// 国际化消息资源文件配置(本系统中主要用于显示/错误消息定制)
@Bean
public
ReloadableResourceBundleMessageSource
messageSource
()
{
ReloadableResourceBundleMessageSource
messageSource
=
new
ReloadableResourceBundleMessageSource
();
messageSource
.
setBasenames
(
"classpath:org/hibernate/validator/ValidationMessages"
);
messageSource
.
setUseCodeAsDefaultMessage
(
false
);
messageSource
.
setDefaultEncoding
(
"UTF-8"
);
messageSource
.
setCacheSeconds
(
60
);
return
messageSource
;
}
// 配置全局的验证器实例
@Override
public
Validator
getValidator
()
{
return
this
.
validator
(
messageSource
());
}
// 配置spring mvc的拦截器
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
}
@Bean
public
ByteArrayHttpMessageConverter
byteMsgConverter
()
{
return
new
ByteArrayHttpMessageConverter
();
}
@Bean
public
StringHttpMessageConverter
stringHttpMessageConverter
()
{
StringHttpMessageConverter
stringHttpMessageConverter
=
new
StringHttpMessageConverter
(
Charset
.
forName
(
"UTF-8"
));
List
<
MediaType
>
list
=
new
ArrayList
<
MediaType
>();
list
.
add
(
MediaType
.
TEXT_PLAIN
);
stringHttpMessageConverter
.
setSupportedMediaTypes
(
list
);
return
stringHttpMessageConverter
;
}
}
src/main/resources/ehcache.xml
View file @
316885a3
...
...
@@ -5,7 +5,23 @@
dynamicConfig=
"true"
>
<diskStore
path=
"java.io.tmpdir/ehcache"
/>
<!-- 系统默认缓存 -->
<defaultCache
maxElementsInMemory=
"50000"
clearOnFlush=
"false"
eternal=
"false"
timeToIdleSeconds=
"3600"
timeToLiveSeconds=
"3600"
overflowToDisk=
"true"
diskSpoolBufferSizeMB=
"1024"
maxElementsOnDisk=
"100000"
diskPersistent=
"false"
diskExpiryThreadIntervalSeconds=
"120"
memoryStoreEvictionPolicy=
"LFU"
transactionalMode=
"off"
>
</defaultCache>
<!-- 全局变量:永不过期-->
<cache
name=
"CONSTANT"
maxElementsInMemory=
"50000"
...
...
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