spring-session-redis

A Spring plugin for spring-session

License

License

Categories

Categories

Redis Data Databases
GroupId

GroupId

com.github.skyding228
ArtifactId

ArtifactId

spring-session-redis
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

spring-session-redis
A Spring plugin for spring-session
Project URL

Project URL

https://github.com/skyding228/spring-session
Source Code Management

Source Code Management

https://github.com/skyding228/spring-session

Download spring-session-redis

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.skyding228/spring-session-redis/ -->
<dependency>
    <groupId>com.github.skyding228</groupId>
    <artifactId>spring-session-redis</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.skyding228/spring-session-redis/
implementation 'com.github.skyding228:spring-session-redis:1.0'
// https://jarcasting.com/artifacts/com.github.skyding228/spring-session-redis/
implementation ("com.github.skyding228:spring-session-redis:1.0")
'com.github.skyding228:spring-session-redis:jar:1.0'
<dependency org="com.github.skyding228" name="spring-session-redis" rev="1.0">
  <artifact name="spring-session-redis" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.skyding228', module='spring-session-redis', version='1.0')
)
libraryDependencies += "com.github.skyding228" % "spring-session-redis" % "1.0"
[com.github.skyding228/spring-session-redis "1.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.springframework.session : spring-session jar 1.3.3.RELEASE
org.springframework.session : spring-session-data-redis jar 1.3.3.RELEASE
redis.clients : jedis jar 2.9.0

provided (3)

Group / Artifact Type Version
javax.servlet : javax.servlet-api jar 3.1.0
org.slf4j : slf4j-api jar 1.7.10
org.springframework : spring-webmvc jar 4.1.4.RELEASE

Project Modules

There are no modules declared in this project.

spring-session

A pluggable module used for configuring spring session with redis,which makes the configuration easier.

using steps

1 add dependency to pom.xml

<dependency>
    <groupId>com.skyding.autoconfigure</groupId>
    <artifactId>spring-session</artifactId>
    <version>1.0</version>
</dependency>

2 register a JedisConnectionFactory

org.springframework.data.redis.connection.jedis.JedisConnectionFactory must be in RootWebApplicationContext,which means your web.xml must includes

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

and register JedisConnectionFactory in applicationContext.xml;

Belows are some simple examples.

  • one node
<bean id="jedisConnFactory " class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory ">
    <property name="hostName" value="localhost"></property>
    <property name="port" value="6379"></property>
</bean>
  • cluster
<bean id="jedisConnFactory " class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory ">
    <constructor-arg name="clusterConfig">
        <bean class="com.skyding.autoconfigure.RedisClusterConfigurationFactory">
            <property name="configurationFile" value="classpath:spring-session-redis.properties"></property>
        </bean>
    </constructor-arg>
</bean>

spring-session-redis.properties

spring.redis.cluster.nodes=127.0.0.1:6379,127.0.0.1:6380
spring.redis.cluster.max-redirects=6

Versions

Version
1.0