Springboot code configuration Redis

in springboot, how to use code to directly configure Redis, without configuration information in properties?
template not found yet.
ask for help.

Mar.05,2021

spring:
  redis:
    database: 0
    host: 192.168.179.128
    port: 6379
    password: 123456 -sharp 
    pool:
      -sharp 
      max-active: 16
      -sharp 
      max-wait: -1
      -sharp 
      max-idle: 16
      -sharp 
      min-idle: 0
    -sharp 
    timeout: 6000

it is generally recommended to use the upstairs configuration for automatic injection, which can switch between stand-alone, sentinel and cluster, and then use @ Autowrite RedisTemplate < Object, Object > template; to inject

if you need code configuration, please refer to: org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration

Menu