convert to spring boot project

This commit is contained in:
thinkgem
2018-01-10 23:39:55 +08:00
parent 7237c524c5
commit a0c71ce81a
39 changed files with 982 additions and 1434 deletions

View File

@@ -0,0 +1,170 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
*/
package com.jeesite.config.spring;
import java.util.Map;
import javax.servlet.Filter;
import org.apache.shiro.cache.CacheManager;
import org.apache.shiro.cas.CasSubjectFactory;
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import com.jeesite.common.config.Global;
import com.jeesite.common.shiro.cas.CasOutHandler;
import com.jeesite.common.shiro.config.FilterChainDefinitionMap;
import com.jeesite.common.shiro.filter.CasAuthenticationFilter;
import com.jeesite.common.shiro.filter.FormAuthenticationFilter;
import com.jeesite.common.shiro.filter.PermissionsAuthorizationFilter;
import com.jeesite.common.shiro.filter.UserFilter;
import com.jeesite.common.shiro.realm.AuthorizingRealm;
import com.jeesite.common.shiro.session.SessionDAO;
import com.jeesite.common.shiro.session.SessionManager;
import com.jeesite.common.shiro.web.ShiroFilterFactoryBean;
import com.jeesite.common.shiro.web.WebSecurityManager;
import com.jeesite.modules.sys.service.EmpUserService;
import com.jeesite.modules.sys.service.UserService;
/**
* Shiro配置
* @author ThinkGem
* @version 2017年11月30日
*/
@SuppressWarnings("deprecation")
@Configuration
public class ShiroConfig {
/**
* 单点登录信息句柄,单点退出用
*/
@Bean
public CasOutHandler casOutHandler() {
return new CasOutHandler();
}
/**
* 系统安全认证实现类
*/
@Bean
public AuthorizingRealm authorizingRealm(SessionDAO sessionDAO, UserService userService,
EmpUserService empUserService, CasOutHandler casOutHandler) {
AuthorizingRealm bean = new AuthorizingRealm();
bean.setCachingEnabled(false);
bean.setSessionDAO(sessionDAO);
bean.setUserService(userService);
bean.setEmpUserService(empUserService);
bean.setCasOutHandler(casOutHandler);
bean.setCasServerUrl(Global.getProperty("shiro.casServerUrl"));
bean.setCasServerCallbackUrl(Global.getProperty("shiro.casClientUrl") + Global.getAdminPath() + "/login-cas");
return bean;
}
/**
* CAS登录过滤器
*/
@Bean
public CasAuthenticationFilter shiroCasFilter(AuthorizingRealm authorizingRealm) {
CasAuthenticationFilter bean = new CasAuthenticationFilter();
bean.setAuthorizingRealm(authorizingRealm);
return bean;
}
/**
* Form登录过滤器
*/
@Bean
public FormAuthenticationFilter shiroAuthcFilter(AuthorizingRealm authorizingRealm) {
FormAuthenticationFilter bean = new FormAuthenticationFilter();
bean.setAuthorizingRealm(authorizingRealm);
return bean;
}
// /**
// * 登出过滤器
// */
// @Bean
// public LogoutFilter shiroLogoutFilter() {
// return new LogoutFilter();
// }
/**
* 权限字符串过滤器
*/
@Bean
public PermissionsAuthorizationFilter shiroPermsFilter() {
return new PermissionsAuthorizationFilter();
}
// /**
// * 角色权限过滤器
// */
// @Bean
// public RolesAuthorizationFilter shiroRolesFilter() {
// return new RolesAuthorizationFilter();
// }
/**
* 用户权限过滤器
*/
@Bean
public UserFilter shiroUserFilter() {
return new UserFilter();
}
/**
* URL过滤定义
*/
@Bean
public FilterChainDefinitionMap shiroFilterChainDefinitionMap() {
FilterChainDefinitionMap bean = new FilterChainDefinitionMap();
bean.setFilterChainDefinitions(Global.getProperty("shiro.filterChainDefinitions"));
bean.setDefaultFilterChainDefinitions(Global.getProperty("shiro.defaultFilterChainDefinitions"));
return bean;
}
/**
* Shiro认证过滤器
*/
@Bean
public ShiroFilterFactoryBean shiroFilter(WebSecurityManager securityManager, CasAuthenticationFilter shiroCasFilter,
FormAuthenticationFilter shiroAuthcFilter,
// LogoutFilter shiroLogoutFilter,
PermissionsAuthorizationFilter shiroPermsFilter,
// RolesAuthorizationFilter shiroRolesFilter,
UserFilter shiroUserFilter, FilterChainDefinitionMap shiroFilterChainDefinitionMap) {
ShiroFilterFactoryBean bean = new ShiroFilterFactoryBean();
bean.setSecurityManager(securityManager);
bean.setLoginUrl(Global.getProperty("shiro.loginUrl"));
bean.setSuccessUrl(Global.getProperty("shiro.successUrl"));
Map<String, Filter> filters = bean.getFilters();
filters.put("cas", shiroCasFilter);
filters.put("authc", shiroAuthcFilter);
// filters.put("logout", shiroLogoutFilter);
filters.put("perms", shiroPermsFilter);
// filters.put("roles", shiroRolesFilter);
filters.put("user", shiroUserFilter);
bean.setFilterChainDefinitionMap(shiroFilterChainDefinitionMap.getObject());
return bean;
}
/**
* 定义Shiro安全管理配置
*/
@Bean
public WebSecurityManager securityManager(AuthorizingRealm authorizingRealm, SessionManager sessionManager, CacheManager shiroCacheManager) {
WebSecurityManager bean = new WebSecurityManager();
bean.setRealm(authorizingRealm);
bean.setSessionManager(sessionManager);
bean.setCacheManager(shiroCacheManager);
// 设置支持CAS的subjectFactory
bean.setSubjectFactory(new CasSubjectFactory());
return bean;
}
}

View File

@@ -80,7 +80,7 @@ jdbc:
redis:
# 是否启用 Redis
enable: false
enabled: false
# Redis 连接参数
host: 192.168.11.12
@@ -101,14 +101,6 @@ redis:
# 是否启用Redis系统缓存及会话
cacheAndSession: false
# Mapper文件刷新线程
mapperRefresh:
enabled: true
delaySeconds: 60
sleepSeconds: 3
mappingPath: mappings
#============================#
#===== System settings ======#
#============================#
@@ -131,6 +123,12 @@ frontPath: /f
#索引页路径
defaultPath: ${adminPath}/login
# 分页配置
page:
# 分页默认大小
pageSize: 20
# 用户相关参数
user:
@@ -185,12 +183,6 @@ user:
# 集团模式多公司、多租户、SAAS模式
useCorpModel: false
# 分页配置
page:
# 分页默认大小
pageSize: 20
# 任务调度
job:
@@ -311,6 +303,14 @@ mybatis:
# 扫描基础包设置Aliases、@MyBatisDao如果多个用“,”分隔
scanBasePackage: com.jeesite.modules
# Mapper文件刷新线程
mapper:
refresh:
enabled: true
delaySeconds: 60
sleepSeconds: 3
mappingPath: mappings
# 缓存设置
ehcache:
@@ -321,6 +321,11 @@ ehcache:
# 清理缓存的缓存名称
clearNames: sysCache,userCache,corpCache,cmsCache,pageCachingFilter
# 页面缓存配置
pageCaching:
enabled: false
urlPatterns: "*.html"
# Web 相关
web:
@@ -332,6 +337,17 @@ web:
# 引入页面为不:'/themes/'+themeName+'/include/footer.html'
themeName: default
# MVC 拦截器
interceptor:
# 后台管理日志记录拦截器
log:
enabled: true
# 前台自动切换到手机视图拦截器
mobile:
enabled: false
# 静态文件后缀,过滤静态文件,以提高访问性能。
staticFile: .css,.js,.map,.png,.jpg,.gif,.jpeg,.bmp,.ico,.swf,.psd,.htc,.crx,.xpi,.exe,.ipa,.apk,.otf,.eot,.svg,.ttf,.woff,.woff2

View File

@@ -1,50 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd"
default-lazy-init="true">
<description>Spring Configuration</description>
<!-- 加载配置属性文件谁先加载谁优先级越高jeesite.yml的优先级高于jeesite-core.yml-->
<bean id="yamlProperties" class="org.springframework.beans.factory.config.YamlPropertiesFactoryBean">
<property name="resources">
<array><value>classpath:jeesite-core.yml</value>
<value>classpath:jeesite.yml</value></array>
</property>
</bean>
<context:property-placeholder properties-ref="yamlProperties" ignore-unresolvable="true"/>
<!-- Spring Application Context Holder -->
<bean id="springUtils" class="com.jeesite.common.utils.SpringUtils" lazy-init="false"></bean>
<!-- 生成唯一性ID工具 -->
<bean id="idGen" class="com.jeesite.common.idgen.IdGen" lazy-init="false"></bean>
<!-- 数据库自动升级程序 -->
<bean id="dbUpgrade" class="com.jeesite.common.db.DbUpgrade" lazy-init="false"></bean>
<!-- 配置国际化资源文件路径 -->
<bean id="messageSource" class="com.jeesite.common.i18n.I18nMessageSource"
depends-on="springUtils">
</bean>
<!-- 基于Cookie和Session的本地化解析器 -->
<bean id="localeResolver" class="com.jeesite.common.i18n.I18nLocaleResolver">
<property name="defaultLocale" value="zh_CN" />
</bean>
<!-- 配置 JSR303 Bean Validator 定义 -->
<bean id="beanValidator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="providerClass" value="org.hibernate.validator.HibernateValidator"/>
</bean>
<!-- 缓存配置 -->
<bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:${ehcache.configFile}" />
</bean>
</beans>

View File

@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd"
default-lazy-init="true">
<description>Spring Redis Configuration</description>
<!-- Druid Spring 监控拦截器 ,开启后部分@Transactional声明式事务会失效暂时还没找到原因 -->
<bean id="druidStatInterceptor" class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor" />
<bean id="druidStatPointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut" scope="prototype">
<property name="patterns"><list>
<value>com.jeesite..*.service..*.*</value>
</list></property>
<property name="excludedPatterns"><list>
<value>com.jeesite..*.service..*Dao.*</value>
</list></property>
</bean>
<aop:config proxy-target-class="true">
<aop:advisor advice-ref="druidStatInterceptor" pointcut-ref="druidStatPointcut" />
</aop:config>
</beans>

View File

@@ -1,112 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd"
default-lazy-init="true">
<description>MyBatis Configuration</description>
<!-- MyBatis SqlSessionFactoryBean -->
<bean id="sqlSessionFactory" class="com.jeesite.common.mybatis.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="typeAliasesPackage" ref="mybatisScanBasePackage"/>
<property name="typeAliasesSuperType" value="com.jeesite.common.entity.BaseEntity"/>
<property name="mapperLocations" value="classpath*:/mappings/**/*.xml"/>
<property name="configLocation" value="classpath:/mybatis/mybatis-config.xml"/>
<property name="configurationProperties"><props>
<prop key="_prefix">${jdbc.tablePrefix}</prop>
</props></property>
</bean>
<!-- 扫描basePackage下所有以@MyBatisDao注解的接口 -->
<bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
<property name="basePackage" ref="mybatisScanBasePackage"/>
<property name="annotationClass" value="com.jeesite.common.mybatis.annotation.MyBatisDao"/>
</bean>
<!-- 定义事务 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 配置 Annotation 驱动,扫描@Transactional注解的类定义事务 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
<!-- 多数据源配置 -->
<bean id="dataSource" class="com.jeesite.common.datasource.RoutingDataSource" primary="true">
<property name="targetDataSources">
<map key-type="java.lang.String"></map>
</property>
<property name="defaultTargetDataSource" ref="defaultDataSource"/>
</bean>
<!-- 默认数据源配置, 使用 Druid 数据库连接池 -->
<bean id="defaultDataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<!-- 数据源驱动类可不写Druid默认会自动根据URL识别DriverClass -->
<property name="driverClassName" value="${jdbc.driver}" />
<!-- 基本属性 url、user、password -->
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<!-- 配置初始化大小、最小、最大 -->
<property name="initialSize" value="${jdbc.pool.init}" />
<property name="minIdle" value="${jdbc.pool.minIdle}" />
<property name="maxActive" value="${jdbc.pool.maxActive}" />
<!-- 配置获取连接等待超时的时间 -->
<property name="maxWait" value="60000" />
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="60000" />
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="300000" />
<!-- 泄露的连接可以被删除的超时值,单位秒
<property name="removeAbandoned" value="true" />
<property name="removeAbandonedTimeout" value="1800" />-->
<!-- 是否检测空闲超时。如果超时,则会被移除 -->
<property name="testWhileIdle" value="true" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<property name="validationQuery" value="${jdbc.testSql}" />
<!-- 打开PSCache并且指定每个连接上PSCache的大小Oracle使用
<property name="poolPreparedStatements" value="true" />
<property name="maxPoolPreparedStatementPerConnectionSize" value="20" /> -->
<!-- 配置监控统计拦截的filters -->
<property name="filters" value="stat" />
<!-- 配置自定义的拦截器 -->
<property name="proxyFilters">
<list>
<bean class="com.jeesite.common.datasource.filter.ConfigFilter" />
</list>
</property>
</bean>
<!-- 数据源配置, 使用应用服务器的数据库连接池
<jee:jndi-lookup id="defaultDataSource" jndi-name="java:comp/env/jdbc/jeesite" />-->
<!-- 数据源配置, 不使用连接池
<bean id="defaultDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>-->
</beans>

View File

@@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"
default-lazy-init="true">
<description>Jedis Configuration</description>
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
<!-- 池中最大空闲链接数 -->
<property name="maxIdle" value="${redis.pool.maxIdle}" />
<!-- 池中最大链接数 -->
<property name="maxTotal" value="${redis.pool.maxTotal}" />
<!-- 当池中链接耗尽,调用者最大阻塞时间,超出此时间将跑出异常。(单位:毫秒;默认为-1表示永不超时 -->
<property name="maxWaitMillis" value="10000" />
<!-- 是否检测空闲超时。如果超时,则会被移除 -->
<property name="testWhileIdle" value="true" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
</bean>
<bean id="jedisPool" class="redis.clients.jedis.JedisPool">
<constructor-arg index="0" ref="jedisPoolConfig" />
<constructor-arg index="1" value="${redis.host}" />
<constructor-arg index="2" value="${redis.port}" type="int" />
<constructor-arg index="3" value="${redis.timeout}" type="int" />
<constructor-arg index="4" value="${redis.password}"/>
<constructor-arg index="5" value="${redis.database}" type="int" />
<constructor-arg index="6" value="${redis.keyPrefix}"/>
<constructor-arg index="7" value="${redis.isSSL}" type="boolean"/>
</bean>
</beans>

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd"
default-lazy-init="true">
<description>Spring EhCache Configuration</description>
<!-- 自定义Session存储容器 -->
<bean id="sessionDAO" class="com.jeesite.common.shiro.session.CacheSessionDAO">
<property name="sessionIdGenerator" ref="idGen" />
<property name="activeSessionsCacheName" value="activeSessionsCache" />
<property name="cacheManager" ref="shiroCacheManager"/>
</bean>
<!-- 自定义系统缓存管理器-->
<bean id="shiroCacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
<property name="cacheManager" ref="ehCacheManager"/>
</bean>
</beans>

View File

@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd"
default-lazy-init="true">
<description>Spring Redis Configuration</description>
<!-- 自定义Session存储容器 -->
<bean id="sessionDAO" class="com.jeesite.common.shiro.session.JedisSessionDAO">
<property name="sessionIdGenerator" ref="idGen" />
<property name="sessionKeyPrefix" value="${redis.keyPrefix}_session_" />
</bean>
<!-- 自定义系统缓存管理器-->
<bean id="shiroCacheManager" class="com.jeesite.common.shiro.cache.JedisCacheManager">
<property name="cacheKeyPrefix" value="${redis.keyPrefix}_cache_" />
</bean>
</beans>

View File

@@ -1,121 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"
default-lazy-init="true">
<description>Shiro Configuration</description>
<!-- Shiro权限过滤过滤器定义 -->
<bean id="shiroFilterChainDefinitionMap" class="com.jeesite.common.shiro.config.FilterChainDefinitionMap">
<!-- 默认的授权过滤定义如果在filterChainDefinitions中已经定义则该定义会被覆盖。-->
<property name="defaultFilterChainDefinitions" value="${shiro.defaultFilterChainDefinitions}"/>
<!-- 自定义的授权过滤器 -->
<property name="filterChainDefinitions" value="${shiro.filterChainDefinitions}"/>
</bean>
<!-- Shiro安全认证过滤器 -->
<bean id="shiroFilter" class="com.jeesite.common.shiro.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager" />
<property name="loginUrl" value="${shiro.loginUrl}" />
<property name="successUrl" value="${shiro.successUrl}" />
<property name="filters">
<map>
<entry key="cas" value-ref="shiroCasFilter" />
<entry key="authc" value-ref="shiroAuthcFilter" />
<entry key="logout" value-ref="shiroLogoutFilter"/>
<entry key="perms" value-ref="shiroPermsFilter"/>
<entry key="roles" value-ref="shiroRolesFilter"/>
<entry key="user" value-ref="shiroUserFilter"/>
</map>
</property>
<property name="filterChainDefinitionMap" ref="shiroFilterChainDefinitionMap"/>
</bean>
<!-- CAS登录过滤器 -->
<bean id="shiroCasFilter" class="com.jeesite.common.shiro.filter.CasAuthenticationFilter">
<property name="authorizingRealm" ref="authorizingRealm"/>
</bean>
<!-- Form登录过滤器 -->
<bean id="shiroAuthcFilter" class="com.jeesite.common.shiro.filter.FormAuthenticationFilter">
<property name="authorizingRealm" ref="authorizingRealm"/>
</bean>
<!-- 登出过滤器 -->
<bean id="shiroLogoutFilter" class="com.jeesite.common.shiro.filter.LogoutFilter"/>
<!-- 权限字符串过滤器 -->
<bean id="shiroPermsFilter" class="com.jeesite.common.shiro.filter.PermissionsAuthorizationFilter"/>
<!-- 角色权限过滤器 -->
<bean id="shiroRolesFilter" class="com.jeesite.common.shiro.filter.RolesAuthorizationFilter"/>
<!-- 用户权限过滤器 -->
<bean id="shiroUserFilter" class="com.jeesite.common.shiro.filter.UserFilter"/>
<!-- 单点登录信息句柄,单点退出用 -->
<bean id="casOutHandler" class="com.jeesite.common.shiro.cas.CasOutHandler"/>
<!-- 系统安全认证实现类 -->
<bean id="authorizingRealm" class="com.jeesite.common.shiro.realm.AuthorizingRealm">
<property name="cachingEnabled" value="false"/>
<property name="sessionDAO" ref="sessionDAO"/>
<property name="userService" ref="userService"/>
<property name="empUserService" ref="empUserService"/>
<property name="casOutHandler" ref="casOutHandler"/>
<property name="casServerUrl" value="${shiro.casServerUrl}"/>
<property name="casServerCallbackUrl" value="${shiro.casClientUrl}${adminPath}/login-cas"/>
</bean>
<!-- 定义Shiro安全管理配置 -->
<bean id="securityManager" class="com.jeesite.common.shiro.web.WebSecurityManager">
<property name="realm" ref="authorizingRealm" />
<property name="sessionManager" ref="sessionManager" />
<!-- shiroCacheManager 在spring-context.xml中定义 -->
<property name="cacheManager" ref="shiroCacheManager" />
<!-- 设置支持CAS的subjectFactory -->
<property name="subjectFactory">
<bean class="org.apache.shiro.cas.CasSubjectFactory"/>
</property>
</bean>
<!-- 自定义会话管理配置 -->
<bean id="sessionManager" class="com.jeesite.common.shiro.session.SessionManager">
<!-- sessionDAO 在spring-context.xml中定义 -->
<property name="sessionDAO" ref="sessionDAO"/>
<!-- 从URL中去掉JSESSIONID串 -->
<property name="sessionIdUrlRewritingEnabled" value="false" />
<!-- 会话超时时间,单位:毫秒 -->
<property name="globalSessionTimeout" value="${session.sessionTimeout}"/>
<!-- 定时清理失效会话, 清理用户直接关闭浏览器造成的孤立会话 -->
<property name="sessionValidationInterval" value="${session.sessionTimeoutClean}"/>
<property name="sessionValidationSchedulerEnabled" value="true"/>
<property name="sessionIdCookie" ref="sessionIdCookie"/>
<property name="sessionIdCookieEnabled" value="true"/>
</bean>
<!-- 指定本系统SESSIONID, 默认为: JSESSIONID 问题: 与SERVLET容器名冲突, 如JETTY, TOMCAT 等默认JSESSIONID,
当跳出SHIRO SERVLET时如ERROR-PAGE容器会为JSESSIONID重新分配值导致登录会话丢失! -->
<bean id="sessionIdCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
<constructor-arg name="name" value="${session.sessionIdCookieName}"/>
</bean>
<!-- 支持Shiro对Controller的方法级AOP安全控制 -->
<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
<property name="securityManager" ref="securityManager"/>
</bean>
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor">
<property name="proxyTargetClass" value="true" />
</bean>
</beans>

View File

@@ -1,150 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd"
default-lazy-init="true">
<description>Spring Configuration Test</description>
<!-- 加载配置属性文件谁先加载谁优先级越高jeesite.yml的优先级高于jeesite-core.yml-->
<bean id="yamlProperties" class="org.springframework.beans.factory.config.YamlPropertiesFactoryBean">
<property name="resources">
<array><value>classpath:jeesite-core.yml</value>
<value>classpath:jeesite.yml</value></array>
</property>
</bean>
<context:property-placeholder properties-ref="yamlProperties" ignore-unresolvable="true"/>
<!-- 使用Annotation自动注册Bean解决事物失效问题在主容器中不扫描@Controller注解在SpringMvc中只扫描@Controller注解。 -->
<context:component-scan base-package="com.jeesite"><!-- base-package 如果多个,用“,”分隔 -->
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<!-- 扫描包设置MyBatis Aliases、MyBatis Mappers -->
<bean name="scanBasePackage" class="java.lang.String">
<constructor-arg><value>com.jeesite</value></constructor-arg>
</bean>
<!-- Spring Application Context Holder -->
<bean id="springUtils" class="com.jeesite.common.utils.SpringUtils" lazy-init="false"></bean>
<!-- MyBatis SqlSessionFactoryBean -->
<bean id="sqlSessionFactory" class="com.jeesite.common.mybatis.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="typeAliasesPackage" ref="scanBasePackage"/>
<property name="typeAliasesSuperType" value="com.jeesite.common.entity.BaseEntity"/>
<property name="mapperLocations" value="classpath*:/mappings/**/*.xml"/>
<property name="configLocation" value="classpath:/mybatis/mybatis-config.xml"></property>
<property name="configurationProperties"><props>
<prop key="_prefix">${jdbc.tablePrefix}</prop>
</props></property>
</bean>
<!-- 扫描basePackage下所有以@MyBatisDao注解的接口 -->
<bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
<property name="basePackage" ref="scanBasePackage"/>
<property name="annotationClass" value="com.jeesite.common.mybatis.annotation.MyBatisDao"/>
</bean>
<!-- 定义事务 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 配置 Annotation 驱动,扫描@Transactional注解的类定义事务 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
<!-- 多数据源配置 -->
<bean id="dataSource" class="com.jeesite.common.datasource.RoutingDataSource">
<property name="targetDataSources">
<map key-type="java.lang.String"></map>
</property>
<property name="defaultTargetDataSource" ref="defaultDataSource"/>
</bean>
<!-- 默认数据源配置, 使用 Druid 数据库连接池 -->
<bean id="defaultDataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<!-- 数据源驱动类可不写Druid默认会自动根据URL识别DriverClass -->
<property name="driverClassName" value="${jdbc.driver}" />
<!-- 基本属性 url、user、password -->
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<!-- 配置初始化大小、最小、最大 -->
<property name="initialSize" value="${jdbc.pool.init}" />
<property name="minIdle" value="${jdbc.pool.minIdle}" />
<property name="maxActive" value="${jdbc.pool.maxActive}" />
<!-- 配置获取连接等待超时的时间 -->
<property name="maxWait" value="60000" />
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="60000" />
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="300000" />
<!-- 泄露的连接可以被删除的超时值,单位秒
<property name="removeAbandoned" value="true" />
<property name="removeAbandonedTimeout" value="1800" />-->
<!-- <property name="validationQuery" value="${jdbc.testSql}" /> -->
<property name="testWhileIdle" value="false" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<!-- 打开PSCache并且指定每个连接上PSCache的大小Oracle使用
<property name="poolPreparedStatements" value="true" />
<property name="maxPoolPreparedStatementPerConnectionSize" value="20" /> -->
<!-- 配置监控统计拦截的filters -->
<property name="filters" value="stat" />
<!-- 配置自定义的拦截器 -->
<property name="proxyFilters">
<list>
<bean class="com.jeesite.common.datasource.filter.ConfigFilter" />
</list>
</property>
</bean>
<!-- 数据库自动升级程序 -->
<bean id="dbUpgrade" class="com.jeesite.common.db.DbUpgrade"></bean>
<!-- 配置国际化资源文件路径 -->
<bean id="messageSource" class="com.jeesite.common.i18n.I18nMessageSource"
depends-on="springUtils">
</bean>
<!-- 基于Cookie和Session的本地化解析器 -->
<bean id="localeResolver" class="com.jeesite.common.i18n.I18nLocaleResolver">
<property name="defaultLocale" value="zh_CN" />
</bean>
<!-- 配置 JSR303 Bean Validator 定义 -->
<bean id="beanValidator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="providerClass" value="org.hibernate.validator.HibernateValidator"/>
</bean>
<!-- 缓存配置 -->
<bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<!-- <property name="configLocation" value="classpath:${ehcache.configFile}" /> -->
</bean>
<!-- 自定义系统缓存管理器-->
<bean id="shiroCacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
<property name="cacheManager" ref="ehCacheManager"/>
</bean>
</beans>

View File

@@ -1,113 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
<description>Spring MVC Configuration</description>
<!-- 加载配置属性文件谁先加载谁优先级越高jeesite.yml的优先级高于jeesite-core.yml-->
<bean id="yamlProperties" class="org.springframework.beans.factory.config.YamlPropertiesFactoryBean">
<property name="resources">
<array><value>classpath:jeesite-core.yml</value>
<value>classpath:jeesite.yml</value></array>
</property>
</bean>
<context:property-placeholder properties-ref="yamlProperties" ignore-unresolvable="true"/>
<!-- 默认的注解映射的支持org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping -->
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" validator="beanValidator">
<mvc:message-converters register-defaults="true">
<!-- 将StringHttpMessageConverter的默认编码设为UTF-8 -->
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg value="UTF-8" />
</bean>
<!-- 将Jackson2HttpMessageConverter的默认格式化输出为false -->
<bean class="com.jeesite.common.web.converter.JsonHttpMessageConverter">
<property name="prettyPrint" value="false"/>
</bean>
<!-- 将Jackson2XmlHttpMessageConverter的默认格式化输出为false -->
<bean class="com.jeesite.common.web.converter.XmlHttpMessageConverter">
<property name="prettyPrint" value="false"/>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<!-- REST中根据MediaType自动判定Content-Type及相应的View -->
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="mediaTypes" >
<value>
json=application/json
xml=application/xml
</value>
</property>
<property name="ignoreAcceptHeader" value="true"/><!-- 忽略accept-header匹配不加后缀使用默认配置 -->
<property name="favorPathExtension" value="true"/><!-- .json、.xml后缀匹配 -->
<property name="favorParameter" value="false"/><!-- format参数名匹配 -->
</bean>
<!-- 定义视图文件解析 -->
<mvc:view-resolvers>
<!-- Beetl主题视图解析器order越小优先级越高 -->
<bean name="viewResolverBeetlThemes" class="com.jeesite.common.beetl.view.BeetlViewResolver">
<property name="prefix" value="/themes/${web.view.themeName}/"/>
<property name="suffix" value=".html" />
<property name="order" value="1000" />
</bean>
<!-- Beetl默认视图文件解析order越小优先级越高 -->
<bean name="viewResolverBeetlDefault" class="com.jeesite.common.beetl.view.BeetlViewResolver">
<property name="prefix" value="/"/>
<property name="suffix" value=".html" />
<property name="order" value="2000" />
</bean>
<!-- JSP主题视图文件解析order越小优先级越高 -->
<bean id="viewResolverJspThemes" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="com.jeesite.common.web.view.JstlView" />
<property name="prefix" value="/WEB-INF/views/themes/${web.view.themeName}/"/>
<property name="suffix" value=".jsp"/>
<property name="order" value="10000"/>
</bean>
<!-- JSP视图文件解析 order越小优先级越高-->
<bean id="viewResolverJspDefault" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="com.jeesite.common.web.view.JstlView" />
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
<property name="order" value="20000"/>
</bean>
<!-- 默认视图定义,根据后缀渲染 -->
<mvc:content-negotiation>
<mvc:default-views>
<bean class="com.jeesite.common.web.view.JsonView">
<property name="prettyPrint" value="false"/>
</bean>
<bean class="com.jeesite.common.web.view.XmlView">
<property name="prettyPrint" value="false"/>
</bean>
</mvc:default-views>
</mvc:content-negotiation>
</mvc:view-resolvers>
<!-- 静态资源映射可读取classes下、jar包里的静态文件 -->
<mvc:resources mapping="/static/**" location="/static/,classpath:/static/" cache-period="31536000"/>
<!-- 对静态资源文件的访问, 将无法mapping到Controller的path交给default servlet handler处理 -->
<mvc:default-servlet-handler/>
<!-- 异常拦截处理异常信息其它异常拦截见BaseController里的@ExceptionHandler注解 -->
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="org.apache.shiro.authz.UnauthenticatedException">error/403</prop>
<prop key="org.apache.shiro.authz.UnauthorizedException">error/403</prop>
<prop key="java.lang.Throwable">error/500</prop>
</props>
</property>
</bean>
<!-- Spring MVC上传文件 MultipartFile 拦截,设置字符集 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding" value="UTF-8" />
</bean>
</beans>

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
<description>Spring MVC Log Interceptor Configuration</description>
<!-- SpringMVC拦截器配置拦截顺序先执行后定义的排在第一位的最后执行。-->
<mvc:interceptors>
<!-- 日志记录拦截器 -->
<mvc:interceptor>
<mvc:mapping path="${adminPath}/**" />
<mvc:exclude-mapping path="${adminPath}"/>
<mvc:exclude-mapping path="${adminPath}/"/>
<mvc:exclude-mapping path="${adminPath}/index"/>
<mvc:exclude-mapping path="${adminPath}/login"/>
<mvc:exclude-mapping path="${adminPath}/sys/log/**"/>
<mvc:exclude-mapping path="${adminPath}/**/listData"/>
<mvc:exclude-mapping path="${adminPath}/**/treeData"/>
<mvc:exclude-mapping path="${adminPath}/sys/menu/tree"/>
<mvc:exclude-mapping path="${adminPath}/sys/online/count"/>
<mvc:exclude-mapping path="${adminPath}/file/ueditor/config"/>
<mvc:exclude-mapping path="${adminPath}/file/fileList"/>
<mvc:exclude-mapping path="${adminPath}/tag/treeselect"/>
<bean class="com.jeesite.modules.sys.interceptor.LogInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
</beans>

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
<description>Spring MVC Log Interceptor Configuration</description>
<!-- SpringMVC拦截器配置拦截顺序先执行后定义的排在第一位的最后执行。-->
<mvc:interceptors>
<!-- 手机视图拦截器 -->
<mvc:interceptor>
<mvc:mapping path="${frontPath}/**" />
<bean class="com.jeesite.modules.sys.interceptor.MobileInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
</beans>