`

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实现session共享

    - **Redis配置**:需要创建一个`JedisConnectionFactory` Bean来配置Redis服务器的信息,如主机名、端口等。 - **Session配置**:通过创建`RedisHttpSessionConfiguration` Bean来指定Session的最大空闲时间等参数。...

    SpringSession+redis共享jar包

    3. 配置SpringSession:创建一个`WebConfig`类,继承自`WebMvcConfigurerAdapter`(如果是Spring Boot 2.x及以上版本,应继承自`WebMvcConfigurationSupport`),并在其中重写`addSessionCustomizers`方法,添加`...

    redis-session-manager-redis-session-manager-2.0.2.zip

    3. **配置文件**:如`config.properties`或`redis.conf`,用于设置Redis Session Manager的各项参数,如Redis服务器的地址、端口、超时时间等。 4. **文档**:可能包含README文件,介绍如何安装、配置和使用这个...

    redis-session-manager-redis-session-manager-2.0.2.tar.gz

    3. **示例**:可能包含示例应用或配置文件,展示如何在实际项目中集成Redis Session Manager。 4. **测试**:单元测试或集成测试代码,验证软件功能的正确性。 5. **依赖库**:可能包含了与Redis Session Manager...

    spring-data-redis-1.0.1

    6. **集成其他Spring组件**:Spring Data Redis可以与Spring Cache、Spring Session等组件无缝集成,实现缓存管理和用户会话管理,进一步提升应用性能和用户体验。 7. **配置与扩展**:1.0.1版本在配置方面进行了...

    redis-session-manager-redis-session-manager-2.2.1.zip

    2. **配置Redis Session Manager**:根据应用类型(如Spring、Node.js等)调整配置文件,设置Redis连接信息。 3. **添加依赖**:在应用的构建文件中添加Redis Session Manager的依赖。 4. **代码集成**:在应用代码...

    redis-session-manager-redis-session-manager-2.0.8.tar.gz

    6. **易于集成**:Redis Session Manager通常与Web框架如Spring Session、Express.js等结合使用,方便开发人员进行会话管理。 **安装与配置** 在Linux环境下,首先需要安装Redis服务器,然后下载并解压“redis-...

    redis-session-manager-redis-session-manager-2.0.0.zip

    2. **配置Redis Session Manager**:将下载的Redis Session Manager 2.0.0集成到Web应用中,配置相应的连接字符串、session过期策略等参数。 3. **测试与调试**:设置好后,可以通过创建和读取session数据来测试是否...

    redis-session-manager-redis-session-manager-2.0.5.zip

    - 集成Redis Session Manager:在Web应用中引入Redis Session Manager的依赖,如Java应用可以使用Spring Session与Redis的集成。配置文件中指定Redis服务器地址、端口、数据库索引等信息,启用Redis作为Session存储...

    spring-session.zip

    集成Spring Session时,需要在Spring Boot或传统Spring应用的配置文件中指定session存储类型,并配置相应的连接参数。例如,对于Redis,需要配置Redis服务器的地址、端口等;对于MongoDB,需要配置数据库名、用户名...

    redis-spring-boot-starter.rar

    3. 调整配置参数:根据实际应用负载调整Redis配置,如超时时间、最大连接数等。 4. 数据备份与恢复:定期进行Redis数据备份,并了解如何恢复,确保数据安全。 总结,`redis-spring-boot-starter`通过简化集成过程...

    tomcat8.5-redis-session-manager-master.zip

    3. **配置Manager**:在Tomcat的`context.xml`或`server.xml`中配置`&lt;Manager&gt;`标签,指定Redis的相关参数,如服务器地址、端口、密码、超时时间等。 4. **配置应用**:在Web应用的`web.xml`中配置Session配置,指定...

    tomcat-redis-session需要的jar包

    3. 如果你的应用使用Spring框架,还需要在Spring配置文件中配置session的监听器,以便在session创建、更新和销毁时进行相应的操作。 4. 重启Tomcat服务器,使新的配置生效。现在,你的应用应该已经开始使用Redis来...

    spring-session例子工程

    3. **启用 Spring Session**:在 Spring Boot 的主配置类上添加 `@EnableRedisHttpSession` 注解,这将启用 Redis 支持的 Session 管理: ```java @SpringBootApplication @EnableRedisHttpSession public class...

    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 session(redis存储方式)监听导致创建大量redisMessageListenerContailner-X线程问题

    我们将从Spring Session的基础知识、Redis在Spring Session中的作用、监听机制导致线程问题的原因以及如何通过配置自定义线程池来解决这一问题等方面进行详细介绍。 首先,Spring Session是一个用于管理用户会话...

    spring-boot mybaits security redis整合

    3. **配置Spring Security**:通过Spring Security的Java配置,定义安全规则,比如哪些URL需要认证,哪些角色有访问权限,实现用户认证和授权。 4. **连接Redis**:配置Redis连接池,创建JedisConnectionFactory,...

    tomcat7-redis-session共享 demo程序

    1. **配置Redis服务器**:确保Redis服务已在本地或远程运行,并配置好相应的网络连接参数。 2. **添加依赖**:在项目中引入Redis相关的库,如`spring-redis`或`jedis`,它们提供了与Redis交互的API。 3. **创建...

    SpringSession+Redis实现Session共享案例

    3. **配置SpringSession与Redis**: - 首先,在项目中引入SpringSession和Redis的相关依赖。 - 配置Spring Boot的`application.properties`或`application.yml`,设置Redis连接信息,如主机名、端口、密码等。 - ...

    Redis、springSession共享包

    3. **配置 SpringSession**:在 Spring Boot 的配置类中,启用 SpringSession 并指定使用 Redis 存储 Session。例如,你可以创建一个 `WebConfigurerAdapter` 的子类,并覆盖 `configureSessionRepository(Session...

Global site tag (gtag.js) - Google Analytics