1. 在 tomcat/lib 中增加以下jar包
commons-pool2-2.4.2.jar
jedis-2.8.0.jar
tomcat-redis-session-manager-2.0.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的写入和读取了