redis + tomcat8.5 session共享
1、tomcat context.xml 参考配置:
<?xml version="1.0" encoding="UTF-8"?> <Context> <!-- Default set of monitored resources. If one of these changes, the --> <!-- web application will be reloaded. --> <WatchedResource>WEB-INF/web.xml</WatchedResource> <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> <!-- redis 单点配置 --> <Valve className="com.naritech.nicole.gump.RedisSessionHandlerValve" /> <Manager className="com.naritech.nicole.gump.RedisSessionManager" host="192.168.1.230" port="6379" database="0" password="xuetz123" maxInactiveInterval="60" /> <!-- redis 哨兵配置 --> <!-- <Valve className="com.naritech.nicole.gump.RedisSessionHandlerValve" /> <Manager className="com.naritech.nicole.gump.RedisSessionManager" sentinels="192.168.9.223:30001,192.168.9.223:30002" sentinelMaster="mymaster" password="123456" maxInactiveInterval="60" /> --> <Resource name="jdbc/xrh_core" auth="Container" type="javax.sql.DataSource" description="MySQL 5.0" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://192.168.1.230/xrh_rds?useSSL=false" username="xrh" password="123456" maxIdle="30" maxWait="10000" maxActive="100"/> </Context>
2、tomcat lib下引入3个jar包:
commons-pool2-2.3.jar、jedis-2.7.3.jar、tomcat-redis-session-manager-master-2.0.0.jar
下载地址如下:https://pan.baidu.com/s/10VGLX-Rxuu-gmGuIOskGRQ
提取密码:tqny
李小家