广告
返回顶部
首页 > 资讯 > 精选 >RedisTemplate方法如何在spring中使用
  • 173
分享到

RedisTemplate方法如何在spring中使用

springredistemplateemp 2023-05-31 13:05:42 173人浏览 薄情痞子
摘要

本篇文章给大家分享的是有关RedisTemplate方法如何在spring中使用,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。需要的jar包 spring-data-Redis

本篇文章给大家分享的是有关RedisTemplate方法如何在spring中使用,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

需要的jar包
spring-data-Redis-1.6.2.RELEASE.jar

jedis-2.7.2.jar(依赖 commons-pool2-2.3.jar)

commons-pool2-2.3.jar

spring-redis.xml 配置文件

<beans xmlns="Http://www.springframework.org/schema/beans"  xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"  xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"  xmlns:aop="http://www.springframework.org/schema/aop"  xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-3.0.xsd   http://www.springframework.org/schema/mvc   http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd    http://www.springframework.org/schema/tx    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd    http://www.springframework.org/schema/aop  http://www.springframework.org/schema/aop/spring-aop-3.0.xsd    http://www.springframework.org/schema/util    http://www.springframework.org/schema/util/spring-util-3.0.xsd"><!--[redis-JedisPoolConfig配置](http://blog.csdn.net/liang_love_java/article/details/50510753)--><!--  jedis-2.7.2.jar 依赖jar包 commons-pool2-2.3.jar     jedis基于 commons-pool2-2.3.jar 自己实现了一个资源池。    配置参数 详见 http://blog.csdn.net/liang_love_java/article/details/50510753-->  <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">     <property name="maxIdle" value="1" />     <property name="maxTotal" value="5" />     <property name="blockWhenExhausted" value="true" />     <property name="maxWaitMillis" value="30000" />     <property name="testOnBorrow" value="true" />   </bean>   <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">     <property name="hostName" value="10.1.8.200" />     <property name="port" value="6379"/>     <property name="poolConfig" ref="jedisPoolConfig" />     <property name="usePool" value="true"/>   </bean>   <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">      <property name="connectionFactory"  ref="jedisConnectionFactory" />      <property name="keySerializer">        <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />      </property>       <property name="valueSerializer">        <bean class="org.springframework.data.redis.serializer.jdkSerializationRedisSerializer" />      </property>      <property name="hashKeySerializer">         <bean class="org.springframework.data.redis.serializer.StringRedisSerializer"/>       </property>      <property name="hashValueSerializer">        <bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer"/>       </property>    </bean> </beans>

--结束END--

本文标题: RedisTemplate方法如何在spring中使用

本文链接: https://www.lsjlt.com/news/225994.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • RedisTemplate方法如何在spring中使用
    本篇文章给大家分享的是有关RedisTemplate方法如何在spring中使用,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。需要的jar包 spring-data-Redis...
    99+
    2023-05-31
    spring redistemplate emp
  • Spring中的RedisTemplate如何使用
    这篇文章主要介绍“Spring中的RedisTemplate如何使用”,在日常操作中,相信很多人在Spring中的RedisTemplate如何使用问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Spring中...
    99+
    2023-07-05
  • RedisTemplate中opsForValue和opsForList方法如何使用
    RedisTemplate中opsForValue和opsForList方法如何使用,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。一、opsForValue用法key:字符...
    99+
    2023-06-20
  • 在spring时使用RedisTemplate如何实现连接并操作Redis
    在spring时使用RedisTemplate如何实现连接并操作Redis?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。事务需要开启enableTransact...
    99+
    2023-05-31
    spring redistemplate redis
  • RedisTemplate中opsForValue和opsForList方法的使用详解
    一、opsForValue用法 key:字符串,value:可以是任意对象Object(例如String、具体对象如自定义类Student等),一个key只能对应一个value。 1...
    99+
    2022-11-12
  • Java中StringRedisTemplate和RedisTemplate的区别及使用方法
    在学习SpringCloud的过程中,总需要记录一下学习的过程,今天记录一下StringRedisTemplate和RedisTemplate的区别及使用方法,使用时只需使用mave...
    99+
    2023-05-15
    StringRedisTemplate RedisTemplate
  • solr语法如何在spring中使用
    今天就跟大家聊聊有关solr语法如何在spring中使用,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。在介绍solr的使用方法之前,我们需要安装solr的服务端集群。基本上就是安装z...
    99+
    2023-05-31
    spring solr
  • 如何在 ASP 中使用 Spring 教程的响应方法?
    在 ASP 中使用 Spring 教程的响应方法 ASP 是一种常用的 Web 应用程序框架,而 Spring 是一种优秀的 Java 开发框架。在 ASP 中使用 Spring 可以提供更加高效、可靠的 Web 应用程序开发方式。本文将介...
    99+
    2023-10-29
    响应 spring 教程
  • spring @Primary-在spring中的使用方式
    spring @Primary在spring的使用 在spring 中使用注解,常使用@Autowired, 默认是根据类型Type来自动注入的。但有些特殊情况,对同一个接口,可能会...
    99+
    2022-11-13
  • @ModelAttribute注解在spring mvc中的使用方法
    @ModelAttribute注解在spring mvc中的使用方法?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。在spring mvc中非常重要的注解@Mod...
    99+
    2023-05-31
    springmvc @modelattribute
  • 在spring boot3中使用native image的最新方法
    目录简介安装GraalVM添加Native Image支持构建spring boot3应用总结简介 在之前spring boot3文章中我们介绍了,spring boot3的一个重要...
    99+
    2023-01-31
    spring boot3使用native image spring boot3 native image
  • spring中redis的使用方法
    这篇文章将为大家详细讲解有关spring中redis的使用方法,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。spring中redis怎么用在Spring中使用RedisJ...
    99+
    2022-10-18
  • Spring中getSingleton的使用方法
    本篇内容主要讲解“Spring中getSingleton的使用方法”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Spring中getSingleton的使用方法”吧!Spring中bean的生命...
    99+
    2023-06-20
  • FactoryBean如何在Spring中使用
    FactoryBean如何在Spring中使用?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。spring  FactoryBean 是创建 复杂的bean,一般的be...
    99+
    2023-05-31
    spring factorybean bea
  • Redis如何在Spring中使用
    本篇文章为大家展示了Redis如何在Spring中使用,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。Eclipse工程结构如下图为我的示例工程的结构图,采用Maven构建。其中需要集成Spring,...
    99+
    2023-05-30
    redis spring
  • transactionAttributes如何在Spring中使用
    本篇文章给大家分享的是有关transactionAttributes如何在Spring中使用,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。具体方法如下:<bean id=...
    99+
    2023-05-31
    spring transactionattributes
  • 时序数据库在Spring Boot中的使用方法
    本篇内容介绍了“时序数据库在Spring Boot中的使用方法”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!InfluxDB简介什么是时序数...
    99+
    2023-06-20
  • 深入浅析JPA在Spring Boot中的使用方法
    深入浅析JPA在Spring Boot中的使用方法?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。什么是JPA一说JavaWeb,很多小伙伴都知道SSH,这个H代表的就是hi...
    99+
    2023-05-31
    springboot jpa
  • Druid如何在Spring Boot中使用
    这篇文章给大家介绍Druid如何在Spring Boot中使用,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。Spring Boot默认的数据源是:org.apache.tomcat.jdbc.pool.DataSour...
    99+
    2023-05-31
    springboot druid
  • 如何在Spring Boot中使用MQTT
    目录为什么选择MQTT MQTT, 启动! 使用方式 Client模式 创建工厂类 创建工具类 Spring Integration 总结 为什么选择MQTT MQTT的定义相信很...
    99+
    2022-11-12
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作