From b6f900dd98a101250e838fb84a05a422b7a122ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Wollschl=C3=A4ger?= Date: Tue, 24 Jan 2023 14:22:43 +0100 Subject: [PATCH 1/2] Add Redis application properties example For the `Connect to Redis` section in the documentation also mention how to configure the Redis connection via application properties similar to the other connectors (Mongodb, Elasticsearch, Neo4j, ...). See gh-33965 --- .../src/docs/asciidoc/data/nosql.adoc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc index d9724f7ca9..d1554e12d1 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc @@ -48,7 +48,20 @@ If you add your own `@Bean` of any of the auto-configured types, it replaces the By default, a pooled connection factory is auto-configured if `commons-pool2` is on the classpath. +Alternatively, you can specify connection details using discrete properties. +For example, you might declare the following settings in your `application.properties`: +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] +---- + spring: + data: + redis: + host: "localhost" + port: 6379 + database: 0 + username: "user" + password: "secret" +---- [[data.nosql.mongodb]] === MongoDB From 2bf780237ad172ebb3c7662114e96632cc8e11bd Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 1 Feb 2023 15:42:59 +0000 Subject: [PATCH 2/2] Polish "Add Redis application properties example" See gh-33965 --- .../src/docs/asciidoc/data/nosql.adoc | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc index d1554e12d1..395ad8d906 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc @@ -34,11 +34,24 @@ TIP: We also provide a `spring-boot-starter-data-redis-reactive` "`Starter`" for [[data.nosql.redis.connecting]] ==== Connecting to Redis You can inject an auto-configured `RedisConnectionFactory`, `StringRedisTemplate`, or vanilla `RedisTemplate` instance as you would any other Spring Bean. -By default, the instance tries to connect to a Redis server at `localhost:6379`. The following listing shows an example of such a bean: include::code:MyBean[] +By default, the instance tries to connect to a Redis server at `localhost:6379`. +You can specify custom connection details using `spring.redis.*` properties, as shown in the following example: + +[source,yaml,indent=0,subs="verbatim",configprops,configblocks] +---- + spring: + redis: + host: "localhost" + port: 6379 + database: 0 + username: "user" + password: "secret" +---- + TIP: You can also register an arbitrary number of beans that implement `LettuceClientConfigurationBuilderCustomizer` for more advanced customizations. `ClientResources` can also be customized using `ClientResourcesBuilderCustomizer`. If you use Jedis, `JedisClientConfigurationBuilderCustomizer` is also available. @@ -48,20 +61,7 @@ If you add your own `@Bean` of any of the auto-configured types, it replaces the By default, a pooled connection factory is auto-configured if `commons-pool2` is on the classpath. -Alternatively, you can specify connection details using discrete properties. -For example, you might declare the following settings in your `application.properties`: -[source,yaml,indent=0,subs="verbatim",configprops,configblocks] ----- - spring: - data: - redis: - host: "localhost" - port: 6379 - database: 0 - username: "user" - password: "secret" ----- [[data.nosql.mongodb]] === MongoDB