1. 在 tomcat/lib 中增加以下jar包
commons-pool2-2.4..jar
jedis-2.8..jar
tomcat-redis-session-manager-2.0..jar
2. 修改tomcat/conf/context.xml, 增加这两行内容
<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
host="localhost" port="6379" database="0" password="foobared" maxInactiveInterval="60"/>
其中,
host: redis host
port: redis port
database: redis database
password: redis password
打开redis命令行监测, 启动tomcat后访问就能看到session的写入和读取了
注:
tomcat-redis-session-manager 尚未对Tomcat8提供支持.
这是给Tomcat8 + JDK8 环境重新编译的 session manager:
src: http://vdisk.weibo.com/s/CYBNl-StmCqr
jar: http://vdisk.weibo.com/s/CYBNl-StmCqk