標籤:instance log 目的 schema jdk can nts class values
由於先前在調試項目的時候需要做單點,但是項目是基於spring-session老版本做的單點登入,沒有實現跨域登入,因為只是針對相同網域名稱下的使用者緩衝進行儲存而已,例如 http://127.0.0.1/wap 和 http://127.0.0.1/wap2 ,這樣的話只要在 第一個網域名稱登入後再去第二2個網域名稱進行使用者登入,則無需重複登入,但是如果是 http://127.0.0.1/wap 和 http://192.168.1/wap2 這樣就沒辦法找到session。
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:c="http://www.springframework.org/schema/c" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd "> <bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxTotal" value="${redis.maxTotal}" /> <property name="maxIdle" value="${redis.maxIdle}" /> <property name="maxWaitMillis" value="${redis.maxWaitMillis}" /> <property name="testOnBorrow" value="${redis.testOnBorrow}" /> </bean> <bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> <property name="hostName" value="${redis.host}" /> <property name="port" value="${redis.port}" /> <property name="password" value="${redis.auth}" /> <property name="poolConfig" ref="poolConfig" /> </bean> <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"> <property name="connectionFactory" ref="connectionFactory" /> <!-- 如果不配置Serializer,那麼儲存的時候智能使用String,如果用物件類型儲存,那麼會提示錯誤對象 can‘t cast to String!!! --> <property name="keySerializer"> <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" /> </property> <property name="valueSerializer"> <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" /> </property> </bean> <bean id="redisTemplateC" class="org.springframework.data.redis.core.RedisTemplate"> <property name="connectionFactory" ref="connectionFactory" /> <property name="keySerializer"> <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" /> </property> <property name="valueSerializer"> <!-- 設定值的序列化器,不然儲存到Redis時會出現十六進位問題 --> <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" /> </property> </bean> <!-- 將session放入redis --> <bean id="redisHttpSessionConfiguration" class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration"> <property name="httpSessionStrategy" ref="cookieHttpSessionStrategy"/> </bean> 設定cookieName和path <bean id="defaultCookieSerializer" class="org.springframework.session.web.http.DefaultCookieSerializer"> <property name="cookieName" value="DTL_SESSION_ID" /> <property name="cookiePath" value="/" /> </bean> <bean id="cookieHttpSessionStrategy" class="org.springframework.session.web.http.CookieHttpSessionStrategy"> <property name="cookieSerializer" ref="defaultCookieSerializer" /> </bean> </beans>
【原】儲存一下之前spring-session的redis單點登入設定檔【跨域】