tomcat session 共享 redis
简单操作,两步骤搞定 tomcat 集群 session共享,用于单点登录,web 集群等
jar包 及配置下载 :http://download.csdn.net/download/knight_black_bob/9821122
1.添加 redis session jar 到 tomcat中
2. 配置 tomcat context.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --><!-- The contents of this file will be loaded for each web application --><Context> <!-- Default set of monitored resources --> <WatchedResource>WEB-INF/web.xml</WatchedResource> <!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> <!-- Uncomment this to enable Comet connection tacking (provides events on session expiration as well as webapp lifecycle) --> <!-- <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" /> --> <Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve"/> <!-- <Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager" database="0" host="localhost" maxInactiveInterval="60" password="123456" port="6379"/> --> <Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager" database="0" host="localhost" maxInactiveInterval="60" port="6379"/> </Context>
本地没有 redis 密码 ,就去掉 password="123456" ....
捐助开发者
在兴趣的驱动下,写一个免费
的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(支持支付宝和微信 以及扣扣群),没钱捧个人场,谢谢各位。
个人主页:http://knight-black-bob.iteye.com/
谢谢您的赞助,我会做的更好!