springboot整合redis

springboot3整合redis 来源于。 阅读详情

1.创建springboot项目 选择依赖

请添加图片描述

2.启动redis服务端 没有去官网下一个 ,傻瓜式安装(window版本)

请添加图片描述

3.在测试类中进行测试

package com.hdjy;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;

@SpringBootTest
class NosqlRedisApplicationTests {

    @Autowired
    private RedisTemplate redisTemplate;
    @Test
    void set() {
        ValueOperations valueOperations = redisTemplate.opsForValue();
        valueOperations.set("name","sun");
    }

    @Test
    void get() {
        ValueOperations valueOperations = redisTemplate.opsForValue();
        Object name = valueOperations.get("name");
        System.out.println(name);
    }
}

执行结果
请添加图片描述

不过这种方法不能跟控制台的redis同步存取,因为控制台存入是字符串类型,RedisTemplate 是以对象的方式存入。如图
请添加图片描述

我们可以使用StringRedisTemplate解决

package com.hdjy;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;

@SpringBootTest
class NosqlRedisApplicationTests2 {

    @Autowired
    private StringRedisTemplate redisTemplate;
    @Test
    void set() {
        ValueOperations valueOperations = redisTemplate.opsForValue();
        valueOperations.set("name","sun");
    }

    @Test
    void get() {
        ValueOperations valueOperations = redisTemplate.opsForValue();
        Object name = valueOperations.get("name");
        System.out.println(name);
    }
}

此时控制台也可以取到
在这里插入图片描述

请添加图片描述

如果想用jedis方式连接redis
1.引入依赖

<dependency>
    <groupId>redis.clients</groupId>
    <artifactId>jedis</artifactId>
</dependency>

2.配置文件中配置信息

spring:
  redis:
    host: localhost
    port: 6379
    client-type: jedis

当不配置jedis时, client-type默认是lettuce

SpringBoot开发——整合Redis SpringBoot整合Redis 阅读详情

相关推荐

DataWorks数据安全治理最佳实践

DataWorks基于数据安全治理的常见思路,针对资产梳理、技术体系建设和运营体系建设,提供了一系列数据安全产品能力,您可通过“基础防护建设、数据安全防护措施及策略增强建设、数据安全持续运营”三个阶段在DataWorks上落地数据安全治理项目。参考本文启动数据安全治理项目前,建议您先了解DataWorks数据安全产品相关能力了解DataWorks数据安全产品能力后,您可参考如下三个阶段在DataWorks上落地数据安全治理项目。

soso1968的博客 1438

在Spring Boot微服务使用ValueOperations操作Redis集群String字符串

记录:443 场景:在Spring Boot微服务使用RedisTemplate的ValueOperations操作Redis集群String字符串类型数据。

zhangbeizhen18的博客 2481

基于STM32的INA226电压电流检测仪

该功率检测装置以STM32F103C8T6微控制器为核心,集成功率检测、数据交互、状态显示和用户提示功能,通过模块化设计实现稳定运行。系统包括按键、LED指示灯、OLED屏幕、INA226电压电流检测、复位电路、晶振电路、蜂鸣器驱动、输入输出接口、调试接口和3.3V降压电路等模块。微控制器通过按键检测用户输入,启动功率检测,采集数据并通过OLED显示,异常情况触发蜂鸣器报警,LED状态指示同步反馈。3.3V降压电路为所有模块提供稳定电源,晶振电路确保时序精度。INA226芯片通过I2C接口与微控制器通信,实

a2784288164的博客 1910

SpringBoot实战第五天

最后在开发一个文件上传接口,结束后端部分开发。

Cary_cacb的博客 1368

[原创]Linux 802.11n CSI tool Monitor模式

Linux 802.11n CSI tool Monitor模式 使用AP模式的缺陷在于ping 命令速度比较慢,且不能精确控制发送的参数,比如接收的包数量是不可控的。Monitor模式可以调制发送速率、发包数量、发送天线个数、HT模式、short/long guard interval等等,因此调通Monitor模式是必须的。期间参考了博主沃一德的CSI Tool安装使用讲解,对他的工作表示感...

u014645508的博客 1万+

Camera | 瑞芯微rk3568平台MIPI-CSI驱动:从设备树到V4L2框架的完整链路解析

本文深入解析瑞芯微rk3568平台MIPI-CSI驱动的完整链路,从设备树配置到V4L2框架集成。详细介绍了rk3568的MIPI-CSI驱动架构、设备树关键节点布局、驱动初始化流程及数据流路径,帮助开发者快速掌握摄像头控制器的调试与优化技巧,实现稳定的视频采集系统。

weixin_28703489的博客 290

spring结合redis如何实现数据的缓存

spring结合redis如何实现数据的缓存 1. 实现目标   通过redis缓存数据字典表的数据。(目的不是加快查询的速度,而是减少数据库的负担)   2. 所需jar包     注意:jdies和commons-pool两个jar的版本是有对应关系的,注意引入jar包是要配对使用,否则将会报错。因为commons-pooljar的目录根据版本的变化,目录结构

yanchenbin88的专栏 1952

零基础学习大气污染模式(WRF、WRF-chem、smoke、camx等)

零基础学习大气污染模式(WRF、WRF-chem、smoke、camx等)

weixin_56135535的博客 654

Springboot整合Redis的基本操作方法

Redis 是完全开源的,遵守 BSD 协议,是一个高性能的 key-value 数据库。Redis支持数据的持久化,可以将内存中的数据保存在磁盘中,重启的时候可以再次加载进行使用。Redis不仅仅支持简单的key-value类型的数据,同时还提供list,set,zset,hash等数据结构的存储。Redis支持数据的备份,即master-slave模式的数据备份。

zzbzxzzdf的博客 750

手把手教你用Chrome DevTools逆向分析抖音a_bogus参数(附完整日志插桩方法)

本文详细介绍了如何使用Chrome DevTools逆向分析抖音a_bogus参数的生成逻辑,包括XHR断点定位、日志插桩追踪和加密核心逻辑解析。通过实战案例,帮助开发者掌握逆向工程技巧,应对抖音接口的动态加密变化,特别适合研究dy接口和a_bogus参数的技术人员。

weixin_27741699的博客 787

Keil5安装多版本共存方案:实用技巧分享

分享Keil5安装过程中实现多版本共存的实用方法,解决开发环境冲突问题。通过合理配置路径与版本管理,让keil5安装更高效稳定,提升嵌入式开发体验。

weixin_42514750的博客 1529

SpringBoot 注解开发

场景:前端发起的频繁的请求,导致服务器压力过大。需要对后端接口进行限流处理,每个接口都需要做限流处理的话就会导致代码冗余,此时就可以利用注解进行解决//时间//次数//这个用于判断是否需要登录,后续可用SpringSecurity + JWT 实现。场景:很多手机号之类的信息需要在前端页面需要进行脱敏处理@Overrideif (value!if (!} else {} else {在返回的对象中使用。

weixin_53630942的博客 481

Python实战:3种高效方法将txt转csv(附pandas对比测试)

本文针对Python中将txt文件转换为csv格式的需求,深度评测了open()、csv模块和pandas三种主流方法。通过详尽的性能对比测试,从执行效率、内存占用和适用场景等维度提供选型指南,帮助开发者根据数据规模与复杂度选择最高效的转换方案。

weixin_29073241的博客 262

springboot 整合redis_Spring Boot 整合 Redis

点击上方“Java学习”,选择“置顶公众号”技术文章第一时间送达!作者 |艾神一不小心https://urlify.cn/zemY7z前言实际开发中缓存处理是必须的,不可能我们每次客户端去请求一次服务器,服务器每次都要去数据库中进行查找,为什么要使用缓存?说到底是为了提高系统的运行速度。将用户频繁访问的内容存放在离用户最近,访问速度最快的地方,提高用户的响应速度,今天先来讲下在 Spr...

weixin_39880328的博客 107

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Spring Boot整合Redis

Redis 基于内存进行存储,支持key-value的存储形式,底层是用C语言进行编写的 基于key-value形式的数据字典,结构简单,没有数据表的概念,直接用键值对形式完成数据的管理。 支持5种数据类型: 字符串 列表 集合 有序集合 哈希 搭建Redis环境 在windows上安装Redis 下载Redis https://github.com/MicrosoftArchive/redis/tags 如不能进入Github,可以到https://download.youkuaiyun.com/downl

zjojk的博客 1万+

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

详解SpringBoot整合Redis

SpringBoot整合Redis 在SpringBoot中一般使用RedisTemplate提供的方法来操作Redis。那么使用SpringBoot整合Redis 需要那些步骤呢。 1.JedisPoolConfig(这个是配置连接池) 2.RedisConnectionFactory(这个是配置连接信息,这里的RedisConnectionFactory是一个接口, 我们需要使用它的实...

XiangYida 12万+

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

【SpringBoot】SpringBoot整合Redis

SpringBoot整合Redis 首先我是在Windows上开发的,因此需要在Windows安装Redis,安装的教程Windows下安装Redis服务,这个教程很容易懂,我按照教程一步一步安装下来,很久就可以运行Redis了。 这个教程在【JAVA】IDEA中SpringBoot整合M...

阳阳的博客 2511

【Spring Boot】SpringBoot整合Redis

SpringBoot整合Redis 1.添加maven依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> 2.配置Redis连接 spring.redis.host=192.168.157.11 spring.re

我们的目标是什么?没有蛀牙!!! 257

SpringBoot整合Redis

今天我们简单使用下spring boot操作redis,废话不多说直接开始整; 环境准备 新建一个spring boot项目 选上这几个,我本地有sptingboot2.6.3版本,我就直接用那个了; 查看项目依赖是否装好 配置文件,其实也不用配,如果你没有配置你的redis,默认也是这个,像我这个默认就是这个都不用配 我们知道redis中有五大基本类型,今天我们就简单学学spri

hello_list的博客 9580

SpringBoot之SpringBoot整合Redis

SpringBoot整合Redis Spring Boot 集成Redis (1)添加redis的起步依赖 (2) 配置redis的连接信息 spring.redis.host=localhost spring.redis.port=6379 (3)注入RedisTemplate测试redis操作 @SpringBootTest class Demo06redisApplicationTests { @Autowired RedisTemplate<String, String

renVictory的博客 203

SpringBoot入门系列(七)Spring Boot整合Redis缓存

前面介绍了Spring Boot 中的整合Mybatis并实现增删改查,。不清楚的朋友可以看看之前的文章:https://www.cnblogs.com/zhangweizhong/category/1657780.html。 今天主要讲解Springboot整合Redis。Redis是目前使用最多的缓存,包括Spring Boot 中我们也是会用Redis做很多事情。那么今天就来说一说...

章为忠的专栏 3129

Spring Boot——整合Redis

Redis(Remote Dictionary Server)是一个开源的内存数据存储系统,它以键值对(key-value)的形式存储数据,并提供了多种数据结构的支持。Spring Boot简介。

秋书一叶的博客 8072

Redis常用操作及springboot整合redis

今天学习了redis的基本操作,通过今天的学习,对于redis的基本的环境的配置,和对于数据库的操作和使用已经可以掌握了,因为rdis这个数据类型,其实是和java中的数据类型是非常的相似的,并且对于其操作也是极其的相似,所以在理解和进行操作上是没有什么问题的。字符串操作的时候,当默认对于key的值进行设置都是更新的操作.当使用setnx进行设置其值的时候,会进行判断这个key时候存在。Redis中的有序集合也是String类型的集合,同样不允许有重复成员,不同的是每个元素都会关联double类型的分数.

m0_74205854的博客 1308
上一篇: 深入理解使用synchronized同步方法和同步代码块的区别
下一篇: springboot整合javaMail
ssdssa
博客等级 码龄7年 139粉丝 35原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值