spring-session之3 redis配置参数配置

spring-session之3 redis配置参数配置

前文,我们 spring-session之2 依葫芦画瓢做个小项目, 做了一个非常简单的小例子,现在我们需要修改redis相关参数,总不能老是使用 localhost:6379 吧, 怎么办? 以及 spring-session还有哪些参数可以修改?

好,今天的目标是:

  1. 修改spring-session redis ip以及端口参数
  2. 了解spring-session redis 还有什么其他参数

1. 修改ip和端口号

为了演示方便, 这里把默认的本地地址(localhost)换成内网地址

先查询下 ipconfig 内网地址

是 10.88.54.169

再修改 spring-session.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
        xmlns:p="http://www.springframework.org/schema/p"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

        <context:annotation-config />

        <!-- RedisHttpSessionConfiguration -->
        <bean class="org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration" />

        <!--JedisConnectionFactory -->
        <bean class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
            <property name="hostName" value="10.88.54.169" />
            <property name="port" value="6379" />
        </bean>
    </beans>

重启应用

项目启动成功

并且成功链接redis

2.JedisConnectionFactory 还有什么其他属性?

通常要看 一个bean 有哪些参数可以设置,看他有什么 set 方法

参数表格一览:

参数类型说明默认
convertPipelineAndTxResultsbooleanSpecifies if pipelined results should be converted to the expected data type. If false, results of JedisConnection.closePipeline() and JedisConnection.exec() will be of the type returned by the Jedis drivertrue
databaseintSets the index of the database used by this connection factory.0
hostNameStringredis 地址localhost
passwordStringpassword used for authenticating with the Redis server.
poolConfigJedisPoolConfigSets the pool configuration for this factorynew JedisPoolConfig()
portintredis 连接端口号6379
shardInfoJedisShardInfoSets the shard info for this factory.
timeoutintredis 连接超时时间2000
usePoolbooleanTurns on or off the use of connection poolingtrue

--to be continued

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值