Spring Redis - Read configuration from application.properties file

后端 未结 9 936
渐次进展
渐次进展 2020-12-25 13:46

I have Spring Redis working using spring-data-redis with all default configuration likes localhost default port and so on.

Now

9条回答
  •  -上瘾入骨i
    2020-12-25 14:24

    Upon looking deeper I found this, could it be what you are looking for?

    # REDIS (RedisProperties)
    spring.redis.database=0 # Database index used by the connection factory.
    spring.redis.host=localhost # Redis server host.
    spring.redis.password= # Login password of the redis server.
    spring.redis.pool.max-active=8 # Max number of connections that can be allocated by the pool at a given time. Use a negative value for no limit.
    spring.redis.pool.max-idle=8 # Max number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections.
    spring.redis.pool.max-wait=-1 # Maximum amount of time (in milliseconds) a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely.
    spring.redis.pool.min-idle=0 # Target for the minimum number of idle connections to maintain in the pool. This setting only has an effect if it is positive.
    spring.redis.port=6379 # Redis server port.
    spring.redis.sentinel.master= # Name of Redis server.
    spring.redis.sentinel.nodes= # Comma-separated list of host:port pairs.
    spring.redis.timeout=0 # Connection timeout in milliseconds. 
    

    Refernce:https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html Searchterm Redis

    From what I can see the values already exist and are defined as

    spring.redis.host=localhost # Redis server host.
    spring.redis.port=6379 # Redis server port.
    

    if you want to create your own properties you can look at my previous post in this thread.

提交回复
热议问题