Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
api
Overview
Overview
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
首航-临时账号
api
Commits
721e1946
Commit
721e1946
authored
Sep 23, 2019
by
java-李谡
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加redis依赖
parent
459ffb43
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
0 deletions
+67
-0
commons-pool2-2.5.0.jar
WebContent/WEB-INF/lib/commons-pool2-2.5.0.jar
+0
-0
jedis-2.9.0.jar
WebContent/WEB-INF/lib/jedis-2.9.0.jar
+0
-0
spring-data-redis-2.0.0.RELEASE.jar
WebContent/WEB-INF/lib/spring-data-redis-2.0.0.RELEASE.jar
+0
-0
redis.properties
resources/redis.properties
+10
-0
spring-context.xml
resources/spring-context.xml
+57
-0
No files found.
WebContent/WEB-INF/lib/commons-pool2-2.5.0.jar
0 → 100644
View file @
721e1946
File added
WebContent/WEB-INF/lib/jedis-2.9.0.jar
0 → 100644
View file @
721e1946
File added
WebContent/WEB-INF/lib/spring-data-redis-2.0.0.RELEASE.jar
0 → 100644
View file @
721e1946
File added
resources/redis.properties
0 → 100644
View file @
721e1946
redis.host
=
106.75.105.96
redis.port
=
7211
redis.auth
=
bbdtek!@#2018
redis.maxTotal
=
100
redis.maxIdle
=
20
redis.maxWaitMillis
=
10000
redis.testOnBorrow
=
true
redis.testOnReturn
=
true
redis.dbIndex
=
3
\ No newline at end of file
resources/spring-context.xml
View file @
721e1946
...
...
@@ -32,6 +32,7 @@
<list>
<value>
classpath:jdbc.properties
</value>
<value>
classpath:ejweb.properties
</value>
<value>
classpath:redis.properties
</value>
</list>
</property>
</bean>
...
...
@@ -141,4 +142,59 @@
<bean
id=
"validator"
class=
"org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"
>
<property
name=
"providerClass"
value=
"org.hibernate.validator.HibernateValidator"
/>
</bean>
<!--设置jedisPool链接池的配置-->
<bean
id=
"jedisPoolConfig"
class=
"redis.clients.jedis.JedisPoolConfig"
>
<property
name=
"maxTotal"
value=
"${redis.maxTotal}"
/>
<property
name=
"maxIdle"
value=
"${redis.maxIdle}"
/>
<property
name=
"maxWaitMillis"
value=
"${redis.maxWaitMillis}"
/>
<property
name=
"testOnBorrow"
value=
"${redis.testOnBorrow}"
/>
<property
name=
"testOnReturn"
value=
"${redis.testOnReturn}"
/>
</bean>
<!--redis链接密码-->
<bean
id=
"redisPassword"
class=
"org.springframework.data.redis.connection.RedisPassword"
>
<constructor-arg
name=
"thePassword"
value=
"${redis.auth}"
></constructor-arg>
</bean>
<!--spring-data-redis2.0以上的配置-->
<bean
id=
"redisStandaloneConfiguration"
class=
"org.springframework.data.redis.connection.RedisStandaloneConfiguration"
>
<property
name=
"hostName"
value=
"${redis.host}"
/>
<property
name=
"port"
value=
"${redis.port}"
/>
<property
name=
"password"
ref=
"redisPassword"
/>
<property
name=
"database"
value=
"${redis.dbIndex}"
/>
</bean>
<!--配置jedis链接工厂 spring-data-redis2.0中
建议改为构造器传入一个RedisStandaloneConfiguration 单机
RedisSentinelConfiguration 主从复制
RedisClusterConfiguration 集群-->
<bean
id=
"jedisConnectionFactory"
class=
"org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
>
<!--spring-data-redis2.0以上建议获取的方式-->
<constructor-arg
name=
"standaloneConfig"
ref=
"redisStandaloneConfiguration"
></constructor-arg>
</bean>
<!--手动设置 key 与 value的序列化方式-->
<bean
id=
"keySerializer"
class=
"org.springframework.data.redis.serializer.StringRedisSerializer"
/>
<bean
id=
"valueSerializer"
class=
"org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer"
/>
<!--配置jedis模板 -->
<bean
id=
"redisTemplate"
class=
"org.springframework.data.redis.core.RedisTemplate"
>
<property
name=
"connectionFactory"
ref=
"jedisConnectionFactory"
/>
<property
name=
"keySerializer"
ref=
"keySerializer"
/>
<property
name=
"valueSerializer"
ref=
"valueSerializer"
/>
<property
name=
"hashKeySerializer"
ref=
"keySerializer"
/>
<property
name=
"hashValueSerializer"
ref=
"valueSerializer"
/>
</bean>
<!--也可以StringRedisTemplate 专注于String的操作 -->
<bean
id=
"stringRedisTemplate"
class=
"org.springframework.data.redis.core.StringRedisTemplate"
>
<!--<property name="connectionFactory" ref="jedisConnectionFactory"></property>-->
<!--在StringRedisTemplate与redisTemplate不同,可以直接造构造器中传入ConnectionFactory-->
<constructor-arg
name=
"connectionFactory"
ref=
"jedisConnectionFactory"
></constructor-arg>
<property
name=
"keySerializer"
ref=
"keySerializer"
/>
<property
name=
"valueSerializer"
ref=
"valueSerializer"
/>
<property
name=
"hashKeySerializer"
ref=
"keySerializer"
/>
<property
name=
"hashValueSerializer"
ref=
"valueSerializer"
/>
</bean>
</beans>
\ 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