tomcat session redis support

1. Go to the official website to download the project, this project is managed by gradle

https://github.com/jcoleman/tomcat-redis-session-manager 

2. After the download is complete, use gradle build to compile. When compiling, if you need to modify the compiled version, please modify the dependencies in the bukld.gradle file. If there is a sign error during the compilation process, please comment the signing segment in build.gradle

3. After the compilation is completed, the required target jar file will appear in the build/libs directory

4. Add in build.gradle

task copyJars(type: Copy) { from configurations.runtime into 'dist’ }

    And re-execute gradle copyJars, so that the dependent files are copied to the dist directory

5. Copy the required tomcat-session-redis.jar and jedis.jar and common-pool2.jar in the dist directory to the tomcat/lib directory

6. Modify tomcat/conf/context.xml, copy the configuration file from README.markdown into it, and modify its parameter values. If redis has a password, add the password parameter item. The demo is as follows:

<ValveclassName="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />  

<ManagerclassName="com.orangefunction.tomcat.redissessions.RedisSessionManager"  

         host = "Your server address"  

         port="6379"  

         password = "your password"  

         database = "Database INDEX used"  

         maxInactiveInterval="60"/>

7. If you need to modify the session cycle, you need to modify the session-config in tomcat/conf/web.xml, because the unit of expire in redis is seconds, and the unit in TOMCAT is minutes, so after integrating redis, The unit here becomes seconds. I need the session timeout to be 30 minutes, which is 30*60

 

 

 

TOMCAT6 is supported in the JDK6 environment. By default, gradle only supports the compilation of JDK7. Therefore, if the JDK environment used by your server is JDK6, then please use the JDK6 environment to compile. Under JDK6, some reports will be reported. Error, these are all generated by using the syntax of JDK7, or because there is no STATE in tomcat, it does not matter, it is OK to modify it, no need to modify the logic inside, just modify the usage and it will be OK, the inside The start and stop methods can be compared with the source code inside, and then recompile, so that tomcat-session-redis.jar will come out. I wrote it step by step. If you have any questions, you can communicate with me.

 

Attached 3 files

demo.zip is a web project written by myself, used to compile tomcat-redis-session-manaager-master-2.0.0.jar by myself

master.zip is a gradle project from the official website. If you need to compile it yourself, you can download it from the official website or download it from here, but the version may be a bit old

tomcat-redis-session-manaager-master-2.0.0.jar is what I spent a long time

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327034183&siteId=291194637