Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# spring-boot-study

Spring Boot教程源码,博客地址:https://blog.csdn.net/gnail_oug



1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<module>spring-boot-scheduling</module>
<module>spring-boot-quartz</module>
<module>spring-boot-quartz-db</module>
<module>spring-boot-session-share</module>
</modules>


Expand Down
12 changes: 12 additions & 0 deletions spring-boot-session-share/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>stayblank</groupId>
<artifactId>spring-boot-session-share</artifactId>
<version>1.0-SNAPSHOT</version>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.songguoliang.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
* @Description
* @Author sgl
* @Date 2018-06-26 10:02
*/
@EnableScheduling
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package stayblank;

import org.springframework.context.annotation.Configuration;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

@Configuration
//maxInactiveIntervalInSeconds 默认是1800秒过期,这里测试修改为60秒
@EnableRedisHttpSession(maxInactiveIntervalInSeconds=60)
public class RedisSessionConfig{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package stayblank;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;


@Controller
@RequestMapping("/")
public class TestController {

@RequestMapping(value="/getSessionId")
@ResponseBody
public String getSessionId(HttpServletRequest request){

Object o = request.getSession().getAttribute("springboot");
if(o == null){
o = "spring boot 牛逼了!!!有端口"+request.getLocalPort()+"生成";
request.getSession().setAttribute("springboot", o);
}

return "端口=" + request.getLocalPort() + " sessionId=" + request.getSession().getId() +"<br/>"+o;
}

}
14 changes: 14 additions & 0 deletions spring-boot-session-share/src/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

server:
port: 8080
session-timeout: 60

spring:
redis:
database: 0
host: 192.168.207.3
port: 6379
password: 123456

session:
store-type: none