Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
shop
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
shop
Commits
633c90d3
Commit
633c90d3
authored
Aug 14, 2018
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加Redis配置,用于数据会话缓存
Change-Id: I292f4875f2548cdd8297a5c626fba6f0c60bbbb3
parent
06184336
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
1 deletion
+44
-1
RedisConfig.java
src/main/java/com/egolm/shop/config/RedisConfig.java
+32
-0
application-dev.properties
src/main/resources/application-dev.properties
+12
-1
No files found.
src/main/java/com/egolm/shop/config/RedisConfig.java
0 → 100644
View file @
633c90d3
package
com
.
egolm
.
shop
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
@Configuration
public
class
RedisConfig
{
@Bean
public
RedisTemplate
<
String
,
?>
getRedisTemplate
(
RedisConnectionFactory
connectionFactory
)
{
RedisTemplate
<
String
,
?>
template
=
new
RedisTemplate
<>();
template
.
setConnectionFactory
(
connectionFactory
);
Jackson2JsonRedisSerializer
<?>
valueSerializer
=
new
Jackson2JsonRedisSerializer
<
Object
>(
Object
.
class
);
ObjectMapper
mapper
=
new
ObjectMapper
();
mapper
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
mapper
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
valueSerializer
.
setObjectMapper
(
mapper
);
template
.
setValueSerializer
(
valueSerializer
);
template
.
setKeySerializer
(
new
StringRedisSerializer
());
template
.
afterPropertiesSet
();
return
template
;
}
}
src/main/resources/application-dev.properties
View file @
633c90d3
...
@@ -20,3 +20,14 @@ spring.datasource.testWhileIdle=true
...
@@ -20,3 +20,14 @@ spring.datasource.testWhileIdle=true
spring.datasource.validationQueryTimeout
=
5
spring.datasource.validationQueryTimeout
=
5
spring.datasource.validationQuery
=
SELECT 1
spring.datasource.validationQuery
=
SELECT 1
spring.datasource.timeBetweenEvictionRunsMillis
=
3600000
spring.datasource.timeBetweenEvictionRunsMillis
=
3600000
spring.redis.database
=
0
spring.redis.host
=
ossip.cn
spring.redis.port
=
6379
spring.redis.password
=
@8UiMqvDtNgv
spring.redis.timeout
=
2000
spring.redis.pool.max-active
=
20
spring.redis.pool.max-wait
=
2000
spring.redis.pool.max-idle
=
5
spring.redis.pool.min-idle
=
0
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment