Redis first contact with the spring session, apart from anything else, start looking at various tutorials on CSDN, then all kinds of Ctrl + c.
First pom.xml, add two dependencies, a lot of Bowen list only a
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
Next, the configuration file application.properties.
spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.redis.password=123
spring.redis.database=0
Pit: password here if redis no password fill in the blank, because the installation redis default password is blank, and then into the following this ok.
spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.redis.password=
spring.redis.database=0
Finally, spring boot startup class Application add comments @EnableRedisHttpSession
@SpringBootApplication
@EnableRedisHttpSession
public class Application extends WebMvcConfigurationSupport {
public static void main(String[] args){
SpringApplication.run(Application.class,args);
}
}
end!