当前位置:网站首页>Install redis on windows and permanently change the password, and integrate redis with the SSM framework
Install redis on windows and permanently change the password, and integrate redis with the SSM framework
2022-06-28 06:00:00 【Coder without code】
First of all redis install , This is introduced in detail in the rookie tutorial , You can do it according to the above . Here is his website :
After installation , Let's start the server first , Get into redis Catalog , Hold down shift And then right-click , Open console . Then input
redis-server.exe redis.windows.confThis opens the server , current redis There is no password , Then repeat the above steps , Input :
redis-cli.exe -h 127.0.0.1 -p 6379 Now it is time to open the client , It's operational .
Before we change the password , You can check whether the client has set a password :
config get requirepassThen we need to change the password , There are two ways to do this , The first is direct code modification , This is only effective when , Restart redis There is no the . The second is to modify redis The configuration file , This will permanently modify . The first setting password code is as follows :
config set requirepass "yourpassword"// Set current password , After the service is restarted, it will be set as the default , No password ; This is not recommended The second one needs to be modified redis Install under directory redis.windows.conf The file , find # requirepass foobared, Then add a line below
requirepass rootpreservation , Now? root That's your password .
Next we need to close redis, Restart . The server startup command has not changed , The client command needs to add a password when logging in :
redis-cli.exe -h 127.0.0.1 -p 6379 -a 123456 // Password parameters need to be added In this way, the password is set successfully .
Then we need to integrate into the framework
First , We need to import dependencies , There may be a mistake in this place , It's the version dependent problem , If you import according to my dependent version, there will be no problem , Otherwise bug Of :
<!-- spring Integrate redis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
<!-- redis -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.8.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.10.RELEASE</version>
</dependency>We are resources Create one in the directory redis.properties file save redis Configuration information :
redis.maxIdle=300
redis.minIdle=100
redis.maxWaitMillis=3000
redis.testOnBorrow=true
redis.maxTotal=500
redis.host=127.0.0.1
redis.port=6379
redis.password=rootthen , We created spring-redis.xml file , Used to configure redis And inheritance :
<?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:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-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/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:property-placeholder location="classpath:redis.properties" ignore-unresolvable="true"/>
<!-- Set data pool -->
<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxIdle" value="${redis.maxIdle}"></property>
<property name="minIdle" value="${redis.minIdle}"></property>
<property name="maxTotal" value="${redis.maxTotal}"></property>
<property name="maxWaitMillis" value="${redis.maxWaitMillis}"></property>
<property name="testOnBorrow" value="${redis.testOnBorrow}"></property>
</bean>
<!-- link redis-->
<bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="hostName" value="${redis.host}"></property>
<property name="port" value="${redis.port}"></property>
<property name="password" value="${redis.password}"></property>
<property name="poolConfig" ref="poolConfig"></property>
</bean>
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
<property name="connectionFactory" ref="connectionFactory"/>
<!-- The following is a selection of serialization methods for various data -->
<property name="keySerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
</property>
<property name="valueSerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
</property>
<property name="hashKeySerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
</property>
<property name="hashValueSerializer">
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
</property>
</bean>
</beans>then , We need to put these configurations into web.xml in , bring tomcat After starting , Just load these configuration files directly :
<!-- mybatis and redis To configure -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-redis.xml,classpath:spring-mybatis.xml</param-value>
</context-param>Now the integration is complete , We can test it , I'll build a new one controller,
package com.mail.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.AddressException;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
/**
* Created by linmeng.
**/
@RestController
public class MailController {
@Resource
private RedisTemplate<String, Object>redisTemplate;
/**
* Send E-mail
*/
@RequestMapping("/email")
public void sendMail(){
Map<String,String> map = new HashMap<>();
map.put("name", "xiaoming");
map.put("age", "18");
redisTemplate.opsForValue().set("name", "xiaoming");
System.out.println(redisTemplate.opsForValue().get("name"));
}
}
If the console can print something , Description can be used in the project .
边栏推荐
- YYGH-8-预约挂号
- PS effect understanding record 2 color_ dodge color_ burn
- Windows环境Redis使用AOF持久化,无法生成AOF文件,生成后无法加载AOF文件内容
- cocoapod中的第三方库怎么引用本地头文件
- Prime mover × Cloud primordial is making sound, reducing cost and increasing efficiency lecture hall
- OpenSCAP 简介
- socke.io长连接实现推送、版本控制、实时活跃用户量统计
- Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
- 1404. 将二进制表示减到1的步骤数
- 原动力×云原生正发声 降本增效大讲堂
猜你喜欢

YYGH-BUG-03

YYGH-8-预约挂号

Binder interview: memory management unit

6. graduation design temperature and humidity monitoring system (esp8266 + DHT11 +oled real-time upload temperature and humidity data to the public network server and display the real-time temperature

Yygh-8-appointment registration

Xcode13.3.1 error reported after pod install
![RL practice (0) - and the platform xinchou winter season [rule based policy]](/img/dc/10d615c64123475fea180e035095ff.png)
RL practice (0) - and the platform xinchou winter season [rule based policy]

Socket. Io long Connection Push, version Control, Real - Time Active user volume Statistics

What is the e-commerce conversion rate so abstract?

Valueerror: iterative over raw text documents expected, string object received
随机推荐
Small ball playing
Shanghai Yuge ASR CAT1 4G module 2-way low power 4G application
【无标题】
death_satan/hyperf-validate
The windows environment redis uses AOF persistence and cannot generate an AOF file. After generation, the content of the AOF file cannot be loaded
Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
V4L2 驱动层分析
socke.io長連接實現推送、版本控制、實時活躍用戶量統計
密码学笔记
Apple MDM Bypass 免越狱绕过MDM配置锁 免费
Apple MDM bypass jailfree bypass MDM configuration lock free
windows上安装redis并永久修改密码,及ssm框架集成redis
Use of JDBC
How the third-party libraries in cocoapod reference local header files
mysql常用函数
idea创建类时自动添加注释
Global country (and region) information JSON data
Typescript interface
Independent station sellers are using the five e-mail marketing skills, do you know?
Jenkins持续集成1