Skip to content

Commit 2bf7802

Browse files
committed
Polish "Add Redis application properties example"
See gh-33965
1 parent b6f900d commit 2bf7802

File tree

1 file changed

+14
-14
lines changed
  • spring-boot-project/spring-boot-docs/src/docs/asciidoc/data

1 file changed

+14
-14
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc

+14-14
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,24 @@ TIP: We also provide a `spring-boot-starter-data-redis-reactive` "`Starter`" for
3434
[[data.nosql.redis.connecting]]
3535
==== Connecting to Redis
3636
You can inject an auto-configured `RedisConnectionFactory`, `StringRedisTemplate`, or vanilla `RedisTemplate` instance as you would any other Spring Bean.
37-
By default, the instance tries to connect to a Redis server at `localhost:6379`.
3837
The following listing shows an example of such a bean:
3938

4039
include::code:MyBean[]
4140

41+
By default, the instance tries to connect to a Redis server at `localhost:6379`.
42+
You can specify custom connection details using `spring.redis.*` properties, as shown in the following example:
43+
44+
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
45+
----
46+
spring:
47+
redis:
48+
host: "localhost"
49+
port: 6379
50+
database: 0
51+
username: "user"
52+
password: "secret"
53+
----
54+
4255
TIP: You can also register an arbitrary number of beans that implement `LettuceClientConfigurationBuilderCustomizer` for more advanced customizations.
4356
`ClientResources` can also be customized using `ClientResourcesBuilderCustomizer`.
4457
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
4861

4962
By default, a pooled connection factory is auto-configured if `commons-pool2` is on the classpath.
5063

51-
Alternatively, you can specify connection details using discrete properties.
52-
For example, you might declare the following settings in your `application.properties`:
5364

54-
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
55-
----
56-
spring:
57-
data:
58-
redis:
59-
host: "localhost"
60-
port: 6379
61-
database: 0
62-
username: "user"
63-
password: "secret"
64-
----
6565

6666
[[data.nosql.mongodb]]
6767
=== MongoDB

0 commit comments

Comments
 (0)