In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
I. the solution of session cluster
1.1.Extending the specified server
Make use of the plug-in function provided by the Servlet container to customize the creation and management policy of HttpSession and replace the default policy by configuration. Disadvantages: coupled with Tomcat/Jetty and other Servlet containers, containers can not be changed at will.
1.2.Using Filter
Using HttpServletRequestWrapper, implement your own getSession () method to take over the creation and management of Session data. Spring-session is realized through this way of thinking.
Spring session support methods in Spring Boot:
JDBC 、 MongoDB 、 Redis 、 Hazelcast 、 HashMap
II. Realization
2.1. Add dependencies
Org.springframework.session spring-session org.springframework.session spring-session-data-redis org.springframework.boot spring-boot-starter-redis
2.2.Configuring application.properties
# spring session starts # spring session uses storage type spring.session.store-type=redis# spring session refresh mode: default on-save#spring.session.redis.flush-mode=on-save#spring.session.redis.namespace=# session timeout Unit second # server.session.timeout=30#spring session end # # redis start # spring.redis.host=192.168.175.13spring.redis .port = 6379spring.redis.password=123456#spring.redis.database=0#spring.redis.pool.max-active=8#spring.redis.pool.max-idle=8#spring.redis.pool.max-wait=-1#spring.redis.pool.min-idle=0#spring.redis.timeout=0#redis ends #
2.3. Testing
Two new applications are created according to the above configuration, one with port 8989 and the other with port 8988. The results are as follows:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.