1. 程式人生 > >IntelliJ IDEA Spring Boot(6) 整合Hibernate+Shiro+Ehcache

IntelliJ IDEA Spring Boot(6) 整合Hibernate+Shiro+Ehcache

   說真的用spring boot 整合整合Hibernate+Shiro+Ehcache。費了我老大的功夫啊。

  但這一切都是值得。

  1. 首先第一點,以前用xml配置shiro的,將失效。錯誤的說法,可以使用xml。

  2. 以前xml中配置的bean,請在加@Configuration註解的類中定義方法並加上註解  

      @Bean,最好寫上name屬性,不然以方法名命名bean的名字

 下面開始配置吧。

  第一: 整合hibernate。這一步驟,http://blog.csdn.net/u011998835/article/details/78369721已經介紹了。但是我稍微做一下修改。

@EnableTransactionManagement
@EnableCaching
@SpringBootApplication
public class SpringbootApplication {

   public static void main(String[] args) {
      SpringApplication.run(SpringbootApplication.class, args);
}

}

這裡不再定義SessionFactory的注入了。改成下面的方式

package com.dashuai.springboot.config;
import 
org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.transaction.annotation.Transactional
; import javax.persistence.EntityManagerFactory; @Configurationpublic class SessionFactoryConfig { @Autowired private EntityManagerFactory entityManagerFactory; @Bean(name="SessionFactory") public SessionFactory getSessionFactory() { if (entityManagerFactory.unwrap(SessionFactory.class) == null) { throw new NullPointerException("factory is not a hibernate factory"); } return entityManagerFactory.unwrap(SessionFactory.class); } }

還有就是我一直忽略的問題,這裡補充一下,就是Druid資料來源監控頁面並沒有配置。

這裡新增一下。

package com.dashuai.springboot.config;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
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;
@Configuration
public class DruidConfig {

    @Bean
public ServletRegistrationBean druidStatView() {
        ServletRegistrationBean registration = new ServletRegistrationBean(new StatViewServlet());
registration.addUrlMappings("/druid/*");
        return registration;
}

    @Bean
public FilterRegistrationBean druidWebStatFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean(new WebStatFilter());
registration.addInitParameter("exclusions","/css/*,/style/*,/js/*,*.js,*.css,/druid*,/attached/*,*.jsp");
registration.addInitParameter("principalSessionName","sessionUser");
registration.addInitParameter("profileEnable","true");
registration.addUrlPatterns("/*");
registration.setOrder(1);
        return registration;
}
}
這裡@Bean我沒有給name屬性賦值,那麼它的值就是 方法名字

其實上述程式碼就是以前web.xml中配置的如下程式碼的轉換

 <!-- //////////////阿里巴巴資料連線池 Druid的監控/////////////////// -->
  <filter>
    <filter-name>druidWebStatFilter</filter-name>
    <filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class>
    <init-param>
      <param-name>exclusions</param-name>
      <param-value>
        /css/*,/style/*,/js/*,*.js,*.css,/druid*,/attached/*,*.jsp
      </param-value>
    </init-param>
    <init-param>
      <param-name>principalSessionName</param-name>
      <param-value>sessionUser</param-value>
    </init-param>
    <init-param>
      <param-name>profileEnable</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>druidWebStatFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <!-- //////////druid監控頁面,使用${pageContext.request.contextPath}/druid/index.html訪問///////// -->
  <servlet>
    <servlet-name>druidStatView</servlet-name>
    <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>druidStatView</servlet-name>
    <url-pattern>/druid/*</url-pattern>
  </servlet-mapping>

上面的整合完畢之後,解析來整合shiro。

以前shiro是配置在 xml中,類似這樣

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">

    <!-- Realm 域 授權和認證的判斷 -->
    <bean id="systemUserRealm" class="com.dashuai.shiro.SystemUserRealm" />
    <bean id="normalUserRealm" class="com.dashuai.shiro.NormalUserRealm" />
    <!-- FormAuthenticationFilter -->
    <bean id="systemAuthFilter" class="com.dashuai.shiro.SystemFormAuthFilter" >
        <property name="loginUrl" value="/admin/login.html" />
        <property name="successUrl" value="/admin/index.html" />
    </bean>
    <bean id="normalAuthFilter" class="com.dashuai.shiro.NormalFormAuthFilter" >
        <property name="loginUrl" value="/login.html" />
        <property name="successUrl" value="/index.html" />
    </bean>

    <bean id="defineModularRealmAuthenticator" class="com.dashuai.shiro.DefautModularRealm">
        <property name="definedRealms">
            <map>
                <entry key="systemAuthorizingRealm" value-ref="systemUserRealm" />
                <entry key="normalAuthorizingRealm" value-ref="normalUserRealm" />
            </map>
        </property>
        <property name="authenticationStrategy">
            <bean class="org.apache.shiro.authc.pam.AtLeastOneSuccessfulStrategy"></bean>
        </property>
    </bean>

    <!-- 安全認證過濾器 -->
   <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
        <property name="securityManager" ref="securityManager" />
        <property name="filters">
            <map>
                <entry key="authsys" value-ref="systemAuthFilter"></entry>
                <entry key="authnor" value-ref="normalAuthFilter"></entry>
            </map>
        </property>
        <property name="filterChainDefinitions">
            <value>
                /res_admin/**=anon
                /res_front/**=anon
                /plugins/**=anon
                /login.html=anon
                /admin/login.*=anon
                /admin/**=authsys
                /user/**=authnor
                /**=anon
            </value>
        </property>
    </bean>

    <!-- 定義Shiro安全管理配置 -->
    <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
        <property name="cacheManager" ref="memoryConstrainedCacheManager" />
        <property name="authenticator" ref="defineModularRealmAuthenticator" />
        <!-- 這裡主要是設定自定義的單Realm應用,若有多個Realm,可使用'realms'屬性代替 -->
        <!-- <property name="realm" ref="loginRealm"/> -->
        <property name="realms"  >
            <list>
                <ref bean="systemUserRealm" />
                <ref bean="normalUserRealm"/>
            </list>
        </property>
        <property name="sessionManager" ref="sessionManager" />
        <property name="rememberMeManager" ref="rememberMeManager"/>
    </bean>

    <!-- 定義授權快取管理器 -->
    <bean id="shiroCacheManager" class="org.apache.shiro.cache.ehcache.EhCacheManager">
        <property name="cacheManagerConfigFile" value="classpath:ehcache.xml" />
    </bean>

    <bean id="memoryConstrainedCacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager" />

    <!-- 自定義會話管理配置 -->
    <!-- 指定本系統SESSIONID, 預設為: JSESSIONID 問題: 與SERVLET容器名衝突, 如JETTY, TOMCAT 等預設JSESSIONID,
        當跳出SHIRO SERVLET時如ERROR-PAGE容器會為JSESSIONID重新分配值導致登入會話丟失! -->
    <bean id="sessionManager"
          class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
        <property name="sessionDAO" ref="sessionDAO" />
        <!-- 會話超時時間,單位:毫秒 -->
        <property name="globalSessionTimeout" value="1800000" />
        <!-- 定時清理失效會話, 清理使用者直接關閉瀏覽器造成的孤立會話 -->
        <property name="sessionValidationInterval" value="1800000" />
        <property name="sessionValidationSchedulerEnabled" value="true" />
        <property name="sessionIdCookie" ref="simpleCookie" />
        <property name="sessionIdCookieEnabled" value="true" />
    </bean>

    <!-- 會話Cookie模板 -->
    <bean id="simpleCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
        <constructor-arg name="name" value="shiro.sesssion"/>
        <property name="path" value="/"/>
    </bean>

    <bean id="rememberMeCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
        <constructor-arg value="rememberMe"/>
        <property name="httpOnly" value="true"/>
        <property name="maxAge" value="604800"/><!-- 7天 -->
    </bean>

    <!-- rememberMe管理器 -->
    <bean id="rememberMeManager"
          class="org.apache.shiro.web.mgt.CookieRememberMeManager">
        <property name="cipherKey"
                  value="#{T(org.apache.shiro.codec.Base64).decode('4AvVhmFLUs0KTA3Kprsdag==')}"/>
        <property name="cookie" ref="rememberMeCookie"/>
    </bean>

    <bean id="sessionDAO"
          class="org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO">
        <property name="cacheManager" ref="shiroCacheManager" />
    </bean>

    <!-- 保證實現了Shiro內部lifecycle函式的bean執行 -->
    <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" />


</beans>

但是用springboot 就不能這樣寫了。應慢慢修改成對應下面的java程式碼,我也是很辛苦的一一對應的寫上的。
package com.dashuai.springboot.config;
import com.dashuai.springboot.shiro.*;
import org.apache.shiro.authc.pam.AtLeastOneSuccessfulStrategy;
import org.apache.shiro.cache.MemoryConstrainedCacheManager;
import org.apache.shiro.cache.ehcache.EhCacheManager;
import org.apache.shiro.realm.Realm;
import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO;
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.CookieRememberMeManager;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.web.servlet.SimpleCookie;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.DelegatingFilterProxy;
import javax.servlet.Filter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@Configuration
public class ShiroConfig {

    @Bean(name = "systemAuthFilter")
    public SystemFormAuthFilter getSystemFormAuthFilter() {
        SystemFormAuthFilter formAuthFilter = new SystemFormAuthFilter();
formAuthFilter.setSuccessUrl("/admin/index.html");
formAuthFilter.setLoginUrl("/admin/login.html");
        return formAuthFilter;
}

    @Bean(name = "normalAuthFilter")
    public NormalFormAuthFilter getNormalFormAuthFilter() {
        NormalFormAuthFilter formAuthFilter = new NormalFormAuthFilter();
formAuthFilter.setSuccessUrl("/index.html");
formAuthFilter.setLoginUrl("/login.html");
        return formAuthFilter;
}

    @Bean(name = "shiroFilter")
    public ShiroFilterFactoryBean getShiroFilterFactoryBean() {
        ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
shiroFilterFactoryBean.setSecurityManager(getDefaultWebSecurityManager());
Map<String, Filter> filters = new LinkedHashMap<>();
filters.put("authsys", getSystemFormAuthFilter());
filters.put("authnor", getNormalFormAuthFilter());
shiroFilterFactoryBean.setFilters(filters);
LinkedHashMap<String, String> filterChainDefinitionMap=new LinkedHashMap<>();
filterChainDefinitionMap.put("/login.html", "anon");
filterChainDefinitionMap.put("/admin/login.*", "anon");
filterChainDefinitionMap.put("/admin", "authsys");
filterChainDefinitionMap.put("/admin/", "authsys");
filterChainDefinitionMap.put("/admin/**.html", "authsys");// 也就是說 這個配置請細緻配置
// filterChainDefinitionMap.put("/admin/**", "authsys");// 不可以加這個,否則/admin/login.*失效
filterChainDefinitionMap.put("/user/**", "authnor");
filterChainDefinitionMap.put("/**", "anon");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
        return shiroFilterFactoryBean;
}

    @Bean(name = "securityManager")
    public DefaultWebSecurityManager getDefaultWebSecurityManager() {
        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setCacheManager(getMemoryConstrainedCacheManager());
securityManager.setAuthenticator(getDefautModularRealm());
ArrayList<Realm> list = new ArrayList<>();
list.add(getSystemUserRealm());
list.add(getNormalUserRealm());
securityManager.setRealms(list);
securityManager.setSessionManager(getDefaultWebSessionManager());
securityManager.setRememberMeManager(getCookieRememberMeManager());
        return securityManager;
}

    @Bean(name = "memoryConstrainedCacheManager")
    public MemoryConstrainedCacheManager getMemoryConstrainedCacheManager() {
        MemoryConstrainedCacheManager manager = new MemoryConstrainedCacheManager();
        return manager;
}

    @Bean(name = "defineModularRealmAuthenticator")
    public DefautModularRealm getDefautModularRealm() {
        DefautModularRealm realm = new DefautModularRealm();
Map<String, Object> definedRealms = new HashMap<>();
definedRealms.put("systemAuthorizingRealm", getSystemUserRealm());
definedRealms.put("normalAuthorizingRealm", getNormalUserRealm());
realm.setDefinedRealms(definedRealms);
realm.setAuthenticationStrategy(new AtLeastOneSuccessfulStrategy());
        return realm;
}

    @Bean(name = "systemUserRealm")
    public SystemUserRealm getSystemUserRealm() {
        SystemUserRealm realm = new SystemUserRealm();
        return realm;
}

    @Bean(name = "normalUserRealm")
    public NormalUserRealm getNormalUserRealm() {
        NormalUserRealm realm = new NormalUserRealm();
        return realm;
}

    @Bean(name = "sessionManager")
    public DefaultWebSessionManager getDefaultWebSessionManager() {
        DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
sessionManager.setSessionDAO(getEnterpriseCacheSessionDAO());
sessionManager.setGlobalSessionTimeout(1800000);
sessionManager.setSessionValidationInterval(1800000);
sessionManager.setSessionIdCookieEnabled(true);
sessionManager.setSessionValidationSchedulerEnabled(true);
sessionManager.setSessionIdCookie(getSimpleCookie());
        return sessionManager;
}

    @Bean(name = "sessionDAO")
    public EnterpriseCacheSessionDAO getEnterpriseCacheSessionDAO() {
        EnterpriseCacheSessionDAO sessionDAO = new EnterpriseCacheSessionDAO();
sessionDAO.setCacheManager(getEhCacheManager());
        return sessionDAO;
}

    @Bean(name = "shiroCacheManager")
    public EhCacheManager getEhCacheManager() {
        EhCacheManager em = new EhCacheManager();
em.setCacheManagerConfigFile("classpath:ehcache.xml");
        return em;
}

    @Bean(name = "simpleCookie")
    public SimpleCookie getSimpleCookie() {
        SimpleCookie simpleCookie = new SimpleCookie("shiro.sesssion");
simpleCookie.setPath("/");
        return simpleCookie;
}

    @Bean(name = "rememberMeManager")
    public CookieRememberMeManager getCookieRememberMeManager() {
        CookieRememberMeManager meManager = new CookieRememberMeManager();
meManager.setCipherKey(org.apache.shiro.codec.Base64.decode("4AvVhmFLUs0KTA3Kprsdag=="));
meManager.setCookie(getRememberMeCookie());
        return meManager;
}

    @Bean(name = "rememberMeCookie")
    public SimpleCookie getRememberMeCookie() {
        SimpleCookie simpleCookie = new SimpleCookie("rememberMe");
simpleCookie.setHttpOnly(true);
simpleCookie.setMaxAge(604800); // 7return simpleCookie;
}

   
// 千萬不要配置這個,這是導致Could not obtain transaction-synchronized Session for current thread產生的原因
// 至於為什麼,弄不清楚
//    @Bean(name = "lifecycleBeanPostProcessor")
//    public LifecycleBeanPostProcessor getLifecycleBeanPostProcessor() {
//        return new LifecycleBeanPostProcessor();
//    }
@Beanpublic FilterRegistrationBean filterRegistrationBean() { FilterRegistrationBean filterRegistration = new FilterRegistrationBean();filterRegistration.setFilter(new DelegatingFilterProxy("shiroFilter"));filterRegistration.addInitParameter("targetFilterLifecycle", "true");filterRegistration.addUrlPatterns("/*"); return filterRegistration;}} 基本上一一對應。但這裡有兩個個巨坑。
LinkedHashMap<String, String> filterChainDefinitionMap=new LinkedHashMap<>();
filterChainDefinitionMap.put("/login.html", "anon");
filterChainDefinitionMap.put("/admin/login.*", "anon");
filterChainDefinitionMap.put("/admin", "authsys");
filterChainDefinitionMap.put("/admin/", "authsys");
filterChainDefinitionMap.put("/admin/**.html", "authsys");// 也就是說 這個配置請細緻配置
// filterChainDefinitionMap.put("/admin/**", "authsys");// 不可以加這個,否則/admin/login.*失效
filterChainDefinitionMap.put("/user/**", "authnor");
filterChainDefinitionMap.put("/**", "anon");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);

就是url的攔截,請細緻小心的配置,不要直接/**什麼的,會導致最基本的登陸請求都完成不了,我就在這吃了大虧。因為在xml中那樣配置沒有問題,但是寫成java程式碼,差點沒坑死我。

 第二個坑,我找了好長好長時間。 因為上一篇只整合hibernate的時候,並沒有報異常。Could not obtain transaction-synchronized Session for current thread

Could not obtain transaction-synchronized Session for current thread

可是加上ShiroConfig,怎麼都報這個異常。剛開始使用配置openSessionInViewFilter,起點作用,但是在單元測試的時候,還是抱上述異常。我就非常納悶,我嘗試先關閉shiroConfig,然後發現單元測試就不報異常了。所以我覺得就是這個的配置,所以我基本一點點註釋,才發現,一旦配置LifecycleBeanPostProcessor,一定報上述異常。

所以這個坑,哎~~~ 傷不起啊。

   忘了沒有修改ehcache.xml中shiro的快取設定了。

<!-- shiro ehcache-->
<!-- 登入記錄快取 鎖定10分鐘 -->
<cache name="passwordRetryCache"
maxElementsInMemory="2000" eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="0"
overflowToDisk="false"
statistics="true">
</cache>
<cache name="authorizationCache"
maxElementsInMemory="2000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="0"
overflowToDisk="false"
statistics="true">
</cache>
<cache name="authenticationCache"
maxElementsInMemory="2000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="0"
overflowToDisk="false"
statistics="true">
</cache>
<cache name="shiro-activeSessionCache"
maxElementsInMemory="2000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="0"
overflowToDisk="false"
statistics="true">
</cache>
<cache name="shiro_cache"
maxElementsInMemory="2000"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
maxElementsOnDisk="0"
overflowToDisk="true"
memoryStoreEvictionPolicy="FIFO"
statistics="true">
</cache>
加上,然後我們執行起來。

log日誌我也粘上來吧。

22:16:10.124 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
22:16:10.125 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
22:16:10.126 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/E:/WorkSpace/springboot/target/classes/]

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.8.RELEASE)

2017-10-28 22:16:10.323  INFO 5840 --- [  restartedMain] c.d.springboot.SpringbootApplication     : Starting SpringbootApplication on DESKTOP-I8M03ML with PID 5840 (E:\WorkSpace\springboot\target\classes started by yaoshuangshuai in E:\WorkSpace\springboot)
2017-10-28 22:16:10.324  INFO 5840 --- [  restartedMain] c.d.springboot.SpringbootApplication     : No active profile set, falling back to default profiles: default
2017-10-28 22:16:10.542  INFO 5840 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]7245da69: startup date [Sat Oct 28 22:16:10 CST 2017]; root of context hierarchy
2017-10-28 22:16:11.496  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'shiroConfig' of type [com.dashuai.springboot.config.ShiroConfig$$EnhancerBySpringCGLIB$$9b51ca65] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:11.658  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'memoryConstrainedCacheManager' of type [org.apache.shiro.cache.MemoryConstrainedCacheManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:11.692  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration' of type [org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration$$EnhancerBySpringCGLIB$$e5568eb1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:11.694  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Generic' of type [org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Generic] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:11.777  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties' of type [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:11.810  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'dataSource' of type [com.alibaba.druid.pool.DruidDataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:11.814  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'inMemoryDatabaseShutdownExecutor' of type [org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration$NonEmbeddedInMemoryDatabaseShutdownExecutor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:11.828  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'spring.jpa-org.springframework.boot.autoconfigure.orm.jpa.JpaProperties' of type [org.springframework.boot.autoconfigure.orm.jpa.JpaProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:11.834  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration' of type [org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration$$EnhancerBySpringCGLIB$$9f067a84] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:11.841  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'spring.transaction-org.springframework.boot.autoconfigure.transaction.TransactionProperties' of type [org.springframework.boot.autoconfigure.transaction.TransactionProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:11.844  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'platformTransactionManagerCustomizers' of type [org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:11.850  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration' of type [org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$7418e39a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:11.864  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jpaVendorAdapter' of type [org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:11.867  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'entityManagerFactoryBuilder' of type [org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:11.903  INFO 5840 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-10-28 22:16:12.012 DEBUG 5840 --- [  restartedMain] o.h.c.internal.RegionFactoryInitiator    : Cache region factory : org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
2017-10-28 22:16:12.119  INFO 5840 --- [  restartedMain] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} inited
2017-10-28 22:16:12.362  WARN 5840 --- [  restartedMain] org.hibernate.id.UUIDHexGenerator        : HHH000409: Using org.hibernate.id.UUIDHexGenerator which does not generate IETF RFC 4122 compliant UUID values; consider using org.hibernate.id.UUIDGenerator instead
2017-10-28 22:16:12.527  INFO 5840 --- [  restartedMain] o.h.cache.spi.UpdateTimestampsCache      : HHH000250: Starting update timestamps cache at region: org.hibernate.cache.spi.UpdateTimestampsCache
2017-10-28 22:16:12.531  INFO 5840 --- [  restartedMain] o.h.cache.internal.StandardQueryCache    : HHH000248: Starting query cache at region: org.hibernate.cache.internal.StandardQueryCache
2017-10-28 22:16:12.594  WARN 5840 --- [  restartedMain] o.h.c.e.AbstractEhcacheRegionFactory     : HHH020003: Could not find a specific ehcache configuration for cache named [com.dashuai.springboot.entity.SystemUser]; using defaults.
2017-10-28 22:16:12.595 DEBUG 5840 --- [  restartedMain] o.h.c.e.AbstractEhcacheRegionFactory     : started EHCache region: com.dashuai.springboot.entity.SystemUser
2017-10-28 22:16:12.596  WARN 5840 --- [  restartedMain] c.e.i.s.EhcacheAccessStrategyFactoryImpl : HHH020007: read-only cache configured for mutable entity [com.dashuai.springboot.entity.SystemUser]
2017-10-28 22:16:12.638  WARN 5840 --- [  restartedMain] o.h.c.e.AbstractEhcacheRegionFactory     : HHH020003: Could not find a specific ehcache configuration for cache named [com.dashuai.springboot.entity.SystemRole]; using defaults.
2017-10-28 22:16:12.639 DEBUG 5840 --- [  restartedMain] o.h.c.e.AbstractEhcacheRegionFactory     : started EHCache region: com.dashuai.springboot.entity.SystemRole
2017-10-28 22:16:12.640  WARN 5840 --- [  restartedMain] c.e.i.s.EhcacheAccessStrategyFactoryImpl : HHH020007: read-only cache configured for mutable entity [com.dashuai.springboot.entity.SystemRole]
2017-10-28 22:16:12.917  INFO 5840 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-10-28 22:16:12.919  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'entityManagerFactory' of type [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.920  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'entityManagerFactory' of type [com.sun.proxy.$Proxy66] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.921  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'sessionFactoryConfig' of type [com.dashuai.springboot.config.SessionFactoryConfig$$EnhancerBySpringCGLIB$$e5b8db62] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.928  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'SessionFactory' of type [org.hibernate.internal.SessionFactoryImpl] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.929  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'systemUserDao' of type [com.dashuai.springboot.dao.impl.SystemUserDaoImpl] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.930  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'systemUserService' of type [com.dashuai.springboot.service.impl.SystemUserServiceImpl] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.930  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'systemUserRealm' of type [com.dashuai.springboot.shiro.SystemUserRealm] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.937  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'normalUserRealm' of type [com.dashuai.springboot.shiro.NormalUserRealm] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.940  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'defineModularRealmAuthenticator' of type [com.dashuai.springboot.shiro.DefautModularRealm] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.952  WARN 5840 --- [  restartedMain] net.sf.ehcache.CacheManager              : Creating a new instance of CacheManager using the diskStorePath "../springBoot_Ehcache" which is already used by an existing CacheManager.
The source of the configuration was net.sf.ehcache.conf[email protected]76292dc5.
The diskStore path for this CacheManager will be set to ../springBoot_Ehcache\ehcache_auto_created_1509200172951.
To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.
2017-10-28 22:16:12.954  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'shiroCacheManager' of type [org.apache.shiro.cache.ehcache.EhCacheManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.958  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'sessionDAO' of type [org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.961  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'simpleCookie' of type [org.apache.shiro.web.servlet.SimpleCookie] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.968  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'sessionManager' of type [org.apache.shiro.web.session.mgt.DefaultWebSessionManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.970  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'rememberMeCookie' of type [org.apache.shiro.web.servlet.SimpleCookie] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.973  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'rememberMeManager' of type [org.apache.shiro.web.mgt.CookieRememberMeManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.978  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'securityManager' of type [org.apache.shiro.web.mgt.DefaultWebSecurityManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.986  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'systemAuthFilter' of type [com.dashuai.springboot.shiro.SystemFormAuthFilter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:12.992  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'normalAuthFilter' of type [com.dashuai.springboot.shiro.NormalFormAuthFilter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:13.027  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cache.annotation.ProxyCachingConfiguration' of type [org.springframework.cache.annotation.ProxyCachingConfiguration$$EnhancerBySpringCGLIB$$53a4b598] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:13.037  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration' of type [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration$$EnhancerBySpringCGLIB$$48187a3c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:13.046  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'spring.cache-org.springframework.boot.autoconfigure.cache.CacheProperties' of type [org.springframework.boot.autoconfigure.cache.CacheProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:13.053  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'cacheManagerCustomizers' of type [org.springframework.boot.autoconfigure.cache.CacheManagerCustomizers] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:13.054  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.cache.SimpleCacheConfiguration' of type [org.springframework.boot.autoconfigure.cache.SimpleCacheConfiguration$$EnhancerBySpringCGLIB$$e9b3ed1d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:13.059  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'cacheManager' of type [org.springframework.cache.concurrent.ConcurrentMapCacheManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:13.059  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'cacheAutoConfigurationValidator' of type [org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration$CacheManagerValidator] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:13.073  INFO 5840 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$a927f7a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-10-28 22:16:13.322  INFO 5840 --- [  restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-10-28 22:16:13.329  INFO 5840 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2017-10-28 22:16:13.330  INFO 5840 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.23
2017-10-28 22:16:13.401  INFO 5840 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-10-28 22:16:13.402  INFO 5840 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2863 ms
2017-10-28 22:16:13.549  INFO 5840 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-10-28 22:16:13.550  INFO 5840 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-10-28 22:16:13.550  INFO 5840 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-10-28 22:16:13.550  INFO 5840 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2017-10-28 22:16:13.550  INFO 5840 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webStatFilter' to urls: [/*]
2017-10-28 22:16:13.550  INFO 5840 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'openSessionInViewFilter' to urls: [/*]
2017-10-28 22:16:13.550  INFO 5840 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'delegatingFilterProxy' to urls: [/*]
2017-10-28 22:16:13.550  INFO 5840 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'systemAuthFilter' to: [/*]
2017-10-28 22:16:13.550  INFO 5840 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'normalAuthFilter' to: [/*]
2017-10-28 22:16:13.550  INFO 5840 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'shiroFilter' to: [/*]
2017-10-28 22:16:13.550  INFO 5840 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'statViewServlet' to [/druid/*]
2017-10-28 22:16:13.551  INFO 5840 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2017-10-28 22:16:13.880  INFO 5840 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot[email protected]7245da69: startup date [Sat Oct 28 22:16:10 CST 2017]; root of context hierarchy
2017-10-28 22:16:13.926  INFO 5840 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/admin/ || /admin/index.html]}" onto public java.lang.String com.dashuai.springboot.controller.AdminController.index()
2017-10-28 22:16:13.926  INFO 5840 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/admin]}" onto public java.lang.String com.dashuai.springboot.controller.AdminController.index2()
2017-10-28 22:16:13.927  INFO 5840 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/admin/login.html]}" onto public java.lang.String com.dashuai.springboot.controller.AdminController.loginIndex()
2017-10-28 22:16:13.928  INFO 5840 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/admin/login.do]}" onto public java.lang.String com.dashuai.springboot.controller.AdminController.doLogin(java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest)
2017-10-28 22:16:13.928  INFO 5840 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/admin/logout.html]}" onto public java.lang.String com.dashuai.springboot.controller.AdminController.logout()
2017-10-28 22:16:13.930  INFO 5840 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-10-28 22:1