Selaa lähdekoodia

springsession support &jars update

springsession support
fastjson ->1.2.74
druid ->1.2.1
Crystal.Sea 4 vuotta sitten
vanhempi
commit
04c7ea987e

+ 7 - 3
build.gradle

@@ -209,7 +209,11 @@ subprojects {
          compile group: 'org.springframework.boot', name: 'spring-boot-starter-log4j2', version:  "${springBootVersion}"
          compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version:  "${springBootVersion}"
          compile group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version:  "${springBootVersion}"
+         compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-redis', version: "${springBootVersion}"
          testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version:  "${springBootVersion}"
+         //spring-session
+         compile group: 'org.springframework.session', name: 'spring-session-core', version: "${springSessionVersion}"
+         compile group: 'org.springframework.session', name: 'spring-session-data-redis', version: "${springSessionVersion}"
          //saml 
          compile group: 'org.opensaml', name: 'opensaml', version: '2.6.4'
          compile group: 'org.opensaml', name: 'openws', version: '1.5.4'
@@ -253,7 +257,7 @@ subprojects {
          compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: "${jacksonVersion}"
          compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: "${jacksonVersion}"
          compile group: 'com.fasterxml', name: 'classmate', version: '1.5.0'
-		 compile group: 'com.alibaba', name: 'fastjson', version: '1.2.73'
+		 compile group: 'com.alibaba', name: 'fastjson', version: '1.2.74'
          //reactive
          compile group: 'org.reactivestreams', name: 'reactive-streams', version: '1.0.2'
          compile group: 'io.projectreactor', name: 'reactor-core', version: '3.2.10.RELEASE'
@@ -262,8 +266,8 @@ subprojects {
          compile group: 'org.quartz-scheduler', name: 'quartz', version: '2.3.2'
 		 //database
 		 compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.21'
-		 compile group: 'com.alibaba', name: 'druid', version: '1.1.24'
-		 compile group: 'com.alibaba', name: 'druid-spring-boot-starter', version: '1.1.24'
+		 compile group: 'com.alibaba', name: 'druid', version: '1.2.1'
+		 compile group: 'com.alibaba', name: 'druid-spring-boot-starter', version: '1.2.1'
          compile group: 'redis.clients', name: 'jedis', version: '3.3.0'
          compile group: 'org.ehcache', name: 'ehcache', version: '3.9.0'
 		 //mybatis

+ 1 - 0
gradle.properties

@@ -7,6 +7,7 @@ log4jVersion         	=2.13.3
 springVersion        	=5.2.9.RELEASE
 springBootVersion    	=2.3.4.RELEASE
 springSecurityVersion	=5.4.0
+springSessionVersion    =2.3.1.RELEASE
 hibernateVersion	 	=6.1.5.Final
 slf4jVersion	 	 	=1.7.30
 jacksonVersion		 	=2.11.2

+ 62 - 0
maxkey-core/src/main/java/org/maxkey/autoconfigure/SessionRedisAutoConfiguration.java

@@ -0,0 +1,62 @@
+/*
+ * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+
+package org.maxkey.autoconfigure;
+
+import org.maxkey.constants.ConstantsProperties;
+import org.maxkey.persistence.redis.RedisConnectionFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
+import org.springframework.session.web.http.CookieSerializer;
+import org.springframework.session.web.http.DefaultCookieSerializer;
+
+@Configuration
+@EnableRedisHttpSession
+@PropertySource(ConstantsProperties.applicationPropertySource)
+public class SessionRedisAutoConfiguration implements InitializingBean {
+    private static final  Logger _logger = LoggerFactory.getLogger(SessionRedisAutoConfiguration.class);
+    
+    private final RedisConnectionFactory redisConnectionFactory;
+
+    public SessionRedisAutoConfiguration(ObjectProvider<RedisConnectionFactory> redisConnectionFactory) {
+        this.redisConnectionFactory = redisConnectionFactory.getIfAvailable();
+    }
+
+    @Bean
+    public CookieSerializer cookieSerializer() {
+        DefaultCookieSerializer serializer = new DefaultCookieSerializer();
+        serializer.setCookieName("JSESSIONID"); 
+        serializer.setCookiePath("/"); 
+        serializer.setDomainNamePattern("^.+?\\.(\\w+\\.[a-z]+)$"); 
+        return serializer;
+    }
+    
+   
+
+ 
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        // TODO Auto-generated method stub
+        
+    }
+}

+ 8 - 1
maxkey-web-manage/src/main/resources/application.properties

@@ -61,7 +61,14 @@ spring.messages.encoding=UTF-8
 #main
 spring.main.banner-mode=log
 spring.main.allow-bean-definition-overriding=true
-
+# Session store type.
+#spring.session.store-type=redis
+# Session timeout. If a duration suffix is not specified, seconds is used.
+#server.servlet.session.timeout=1800
+# Sessions flush mode.
+#spring.session.redis.flush-mode=on_save 
+# Namespace for keys used to store sessions.
+#spring.session.redis.namespace=spring:session 
 ###########\u3010Kafka\u96c6\u7fa4\u3011###########
 spring.kafka.bootstrap-servers=localhost:9092
 ###########\u3010\u521d\u59cb\u5316\u751f\u4ea7\u8005\u914d\u7f6e\u3011###########

+ 8 - 0
maxkey-web-maxkey/src/main/resources/application.properties

@@ -69,6 +69,14 @@ spring.messages.encoding=UTF-8
 #main
 spring.main.banner-mode=log
 spring.main.allow-bean-definition-overriding=true
+# Session store type.
+#spring.session.store-type=redis
+# Session timeout. If a duration suffix is not specified, seconds is used.
+#server.servlet.session.timeout=1800
+# Sessions flush mode.
+#spring.session.redis.flush-mode=on_save 
+# Namespace for keys used to store sessions.
+#spring.session.redis.namespace=spring:session 
 
 ###########\u3010Kafka\u96c6\u7fa4\u3011###########
 spring.kafka.bootstrap-servers=localhost:9092