`

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 方法

参数表格一览:

参数 类型 说明 默认
convertPipelineAndTxResults boolean Specifies 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 driver true
database int Sets the index of the database used by this connection factory. 0
hostName String redis 地址 localhost
password String password used for authenticating with the Redis server.
poolConfig JedisPoolConfig Sets the pool configuration for this factory new JedisPoolConfig()
port int redis 连接端口号 6379
shardInfo JedisShardInfo Sets the shard info for this factory.
timeout int redis 连接超时时间 2000
usePool boolean Turns on or off the use of connection pooling true

--to be continued

0
0
分享到:
评论

相关推荐

    spring-session-redis-explorer:Spring Session Data Redis的资源管理器

    session-redis-explorer.jar然后访问配置配置描述spring.redis.host Redis服务器的主机名spring.redis.port Redis服务器的端口server.port 传入HTTP请求的侦听端口您可以通过几种方式(命令行参数, application.yml...

    spring-boot示例项目

    data-redis|[lettuce,redis,session redis,YAML配置,连接池,对象存储](https://github.com/smltq/spring-boot-demo/blob/master/data-redis/HELP.md) quartz|[Spring Scheduler,Quartz,分布式调度,集群,mysql持久化...

    SpringMVC-Mybatis-Shiro-redis-master 权限集成缓存中实例

    这里之前的配置有问题,因为参数类型不一致,有时候jar和环境的问题,导致参数根据index对应,会处理问题, 理论上加另一个 name,就可以解决,现在把name 和type都加上,更保险。 --&gt; 二、登录获取上一个URL...

    springboot学习思维笔记.xmind

    spring-boot-starter-redis spring-boot-starter-security spring-boot-starter-social-facebook spring-boot-starter-social-linkedin spring-boot-starter-social-twitter spring-...

    单点登录源码

    MyBatis | ORM框架 | [http://www.mybatis.org/mybatis-3/zh/index.html](http://www.mybatis.org/mybatis-3/zh/index.html) MyBatis Generator | 代码生成 | [http://www.mybatis.org/generator/index.html]...

    springboot参考指南

    从Spring配置分离@Entity定义 v. 67.5. 配置JPA属性 vi. 67.6. 使用自定义的EntityManagerFactory vii. 67.7. 使用两个EntityManagers viii. 67.8. 使用普通的persistence.xml ix. 67.9. 使用Spring Data JPA和...

    SpringMVC基础上的web框架

    首页修改 dateformat.js 时间参数转换 SpringMVC配置文件集中 快递参数接口 1.1.4 des加解密字符串和文件 1.1.5 redis 加锁,redis升级成2.8.2 freemarker工具类 1.1.6 spring websocket 实现在线聊天 maven升级...

    SpringAll_wuyouzhuguli.tar.gz

    循序渐进,学习Spring Boot、Spring Boot & Shiro、Spring Cloud、Spring Security & Spring Security OAuth2,博客Spring系列源码 一、Spring Boot教程 开启Spring Boot Spring Boot基础配置 Spring Boot中使用...

    Java秒杀系统方案优化高性能高并发学习实战源代码以及笔记..zip

    学习了自己通过 cookie 实现分布式session, 不使用spring boot默认提供的 知识点 数据库设计 明文密码两次md5处理 JSR303参数校验 + 全局异常处理器 分布式session, 通过cookie完成分布式session功能. 将cookie存放...

    基于Spring MVC的web框架 1.1.11

    首页修改 dateformat.js 时间参数转换 SpringMVC配置文件集中 快递参数接口 1.1.4 des加解密字符串和文件 1.1.5 redis 加锁,redis升级成2.8.2 freemarker工具类 1.1.6 spring websocket 实现在线聊天 maven升级...

    "优雅的SSM框架"进行完善(页面分离+nginx负载均衡+tomcat集群)

    Maven Spring(IOC DI AOP 声明式事务处理) SpringMVC(支持Restful风格) Hibernate Validate(参数校验) Mybatis(最少配置方案) ...Tomcat集群(Redis共享Session) Sping Shiro权限控制(待完善)

    基于SpringMVC的一个web框架

    首页修改 dateformat.js 时间参数转换 SpringMVC配置文件集中 快递参数接口 1.1.4 des加解密字符串和文件 1.1.5 redis 加锁,redis升级成2.8.2 freemarker工具类 1.1.6 spring websocket 实现在线聊天 maven升级...

    一个可以直接运行的基于SpringMVC的web框架1.1.12

    首页修改 dateformat.js 时间参数转换 SpringMVC配置文件集中 快递参数接口 1.1.4 des加解密字符串和文件 1.1.5 redis 加锁,redis升级成2.8.2 freemarker工具类 1.1.6 spring websocket 实现在线聊天 maven升级...

    iBase4J分布式系统-其他

    Spring-Session日志管理:SLF4J、Log4j2前端框架:Angular JS + Bootstrap + Jquery启动说明:* 项目依赖activemq、Redis和ZooKeeper服务。* 使用nginx代理UI:修改配置里的UI目录后重启nginx。* 启动方法:...

    可以直接运行的基于SpringMVC的web框架示例,也可以直接当公司框架

    首页修改 dateformat.js 时间参数转换 SpringMVC配置文件集中 快递参数接口 1.1.4 des加解密字符串和文件 1.1.5 redis 加锁,redis升级成2.8.2 freemarker工具类 1.1.6 spring websocket 实现在线聊天 maven升级...

    基于springboot的设备管理系统+源代码+文档说明

    - 支持分布式部署,session存储在redis中 - 友好的代码结构及注释,便于阅读及二次开发 - 引入quartz定时任务,可动态完成任务的添加、修改、删除、暂停、恢复及日志查看等功能 - 页面交互使用Vue2.x,极大的提高了...

    【JeeSpringCloud v3.2.4】后台权限管理系统+互联网云快速开发框架+微服务分布式代码生成

    参数管理:对系统动态配置常用参数。 通知公告:系统通知公告信息发布维护。 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。 登录日志:系统登录日志记录查询包含登录异常。 在线用户:当前...

    【JeeSpringCloud v3.2.4】后台权限管理系统+互联网云快速开发框架+微服务分布式代码生成.zip

    参数管理:对系统动态配置常用参数。 通知公告:系统通知公告信息发布维护。 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。 登录日志:系统登录日志记录查询包含登录异常。 在线用户:当前...

    iBase4J项目

    基于SpringBoot 2.0,SpringMVC,Mybatis,mybatis-plus,motan/dubbo分布式,Redis缓存,Shiro权限管理,redis管理Session,Quartz分布式集群调度,Restful服务;系统管理:包括用户管理、权限管理、数据字典、系统...

Global site tag (gtag.js) - Google Analytics