Springboot integration redis step

First, the addition of dependence


		<dependency>
			<groupId>com.github.spt-oss</groupId>
			<artifactId>spring-boot-starter-data-redis</artifactId>
			<version>2.0.7.0</version>
		</dependency>
redis dependence

Second, add redis.properties profile

Redis # (RedisProperties) 
# the Redis database indexes (default 0) 
spring.redis.database = 0 
# the Redis server address 
spring.redis.host = 127.0.0.1 
# the Redis server port 
spring.redis.port = 6379 
# server connected to the Redis password (blank by default) 
spring.redis.password = 123456 
# connection pool maximum number of connections (negative values no limit) 
spring.redis.pool.max. 8-Active = 
# latency connection pool maximum blocking (negative values are represented There is no limit) 
spring.redis.pool.max -1 = the wait- 
# connection pool maximum idle connection 
spring.redis.pool.max. 8-iDLE = 
# minimum connection pool idle connections 
spring.redis.pool.min- 0 = IDLE 
# connection time (ms) 
# connection pool can be added without providing 
spring.redis.timeout = 2000ms
redis profile

Third, the configuration file is loaded redis.properties

On @SpringBootApplication annotated classes plus

@PropertySource({ "classpath:redis.properties" })

Fourth, the operation target acquisition

Get operated object redis

@Autowired
private RedisTemplate<String, String> redisTemplate;

Guess you like

Origin www.cnblogs.com/mowen120/p/11953707.html