Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
admin
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
曲欣亮
admin
Commits
2dfe1d79
Commit
2dfe1d79
authored
Aug 27, 2019
by
张永
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加redis
parent
b31f10b6
Pipeline
#168
failed with stages
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
4 deletions
+77
-4
pom.xml
pom.xml
+4
-0
RedisConfig.java
src/main/java/com/egolm/admin/config/RedisConfig.java
+34
-0
application-dev.properties
src/main/resources/application-dev.properties
+13
-2
application-pro.properties
src/main/resources/application-pro.properties
+14
-1
application-test.properties
src/main/resources/application-test.properties
+12
-1
No files found.
pom.xml
View file @
2dfe1d79
...
...
@@ -26,6 +26,10 @@
<artifactId>
spring-boot-devtools
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
...
...
src/main/java/com/egolm/admin/config/RedisConfig.java
0 → 100644
View file @
2dfe1d79
package
com
.
egolm
.
admin
.
config
;
import
org.springframework.beans.factory.annotation.Qualifier
;
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
@Qualifier
(
"redisTemplate"
)
public
RedisTemplate
<
String
,
?>
redisTemplate
(
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 @
2dfe1d79
...
...
@@ -10,7 +10,7 @@ spring.http.multipart.maxRequestSize=5MB
spring.http.encoding.force
=
true
spring.http.encoding.enabled
=
true
spring.http.encoding.charset
=
utf-8
spring.main.allow-bean-definition-overriding
=
true
spring.datasource.config.url
=
jdbc:mysql://10.10.0.20:3306/msgcenter?useSSL=false
spring.datasource.config.username
=
root
...
...
@@ -28,4 +28,15 @@ spring.datasource.shop.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerD
spring.datasource.shop.testWhileIdle
=
true
spring.datasource.shop.validationQueryTimeout
=
5
spring.datasource.shop.validationQuery
=
SELECT 1
spring.datasource.shop.timeBetweenEvictionRunsMillis
=
3600000
\ No newline at end of file
spring.datasource.shop.timeBetweenEvictionRunsMillis
=
3600000
######redis
spring.redis.host
=
10.10.0.15
spring.redis.port
=
16379
spring.redis.database
=
10
spring.redis.password
=
spring.redis.timeout
=
3000
spring.redis.jedis.max-active
=
5
spring.redis.jedis.max-idle
=
5
spring.redis.jedis.max-wait
=
5
\ No newline at end of file
src/main/resources/application-pro.properties
View file @
2dfe1d79
...
...
@@ -11,6 +11,8 @@ spring.http.encoding.force=true
spring.http.encoding.enabled
=
true
spring.http.encoding.charset
=
utf-8
spring.main.allow-bean-definition-overriding
=
true
spring.datasource.config.url
=
jdbc:mysql://10.10.0.20:3306/msgcenter?useSSL=false
spring.datasource.config.username
=
root
...
...
@@ -28,4 +30,15 @@ spring.datasource.shop.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerD
spring.datasource.shop.testWhileIdle
=
true
spring.datasource.shop.validationQueryTimeout
=
5
spring.datasource.shop.validationQuery
=
SELECT 1
spring.datasource.shop.timeBetweenEvictionRunsMillis
=
3600000
\ No newline at end of file
spring.datasource.shop.timeBetweenEvictionRunsMillis
=
3600000
######redis
spring.redis.host
=
10.10.0.15
spring.redis.port
=
16379
spring.redis.database
=
10
spring.redis.password
=
spring.redis.timeout
=
3000
spring.redis.jedis.max-active
=
5
spring.redis.jedis.max-idle
=
5
spring.redis.jedis.max-wait
=
5
\ No newline at end of file
src/main/resources/application-test.properties
View file @
2dfe1d79
...
...
@@ -11,6 +11,7 @@ spring.http.encoding.force=true
spring.http.encoding.enabled
=
true
spring.http.encoding.charset
=
utf-8
spring.main.allow-bean-definition-overriding
=
true
spring.datasource.config.url
=
jdbc:mysql://10.10.0.20:3306/msgcenter?useSSL=false
spring.datasource.config.username
=
root
...
...
@@ -28,4 +29,14 @@ spring.datasource.shop.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerD
spring.datasource.shop.testWhileIdle
=
true
spring.datasource.shop.validationQueryTimeout
=
5
spring.datasource.shop.validationQuery
=
SELECT 1
spring.datasource.shop.timeBetweenEvictionRunsMillis
=
3600000
\ No newline at end of file
spring.datasource.shop.timeBetweenEvictionRunsMillis
=
3600000
######redis
spring.redis.host
=
10.10.0.15
spring.redis.port
=
16379
spring.redis.database
=
10
spring.redis.password
=
spring.redis.timeout
=
3000
spring.redis.jedis.max-active
=
5
spring.redis.jedis.max-idle
=
5
spring.redis.jedis.max-wait
=
5
\ 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