1.Redis

一、 添加依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

二、 配置文件:

application.properties文件中,可以参考多环境配置根据不同环境配置不同的库

#redis
spring.redis.host=localhost
spring.redis.port=6379
#spring.redis.password=123456
#spring.redis.database=0
#spring.redis.pool.max-active=8
#spring.redis.pool.max-idle=8
#spring.redis.pool.max-wait=-1
#spring.redis.pool.min-idle=0
#spring.redis.timeout=0

三、测试

主要涉及文件

component/DemoRedisComponent.java

测试类

注:生产环境下,如果外网可以访问,一定要设置密码!

Last updated

Was this helpful?