Harmonize data configuration
Any classes that rely on Spring Data being on the classpath have been moved under a data package. Certain configuration properties have also been updated to accurately reflect whether Spring Data is required for the auto-configuration to work. Closes gh-11574
This commit is contained in:
@@ -326,17 +326,16 @@ There is a `spring-boot-starter-data-cassandra` "`Starter`" for collecting the d
|
||||
[[data.nosql.cassandra.connecting]]
|
||||
==== Connecting to Cassandra
|
||||
You can inject an auto-configured `CassandraTemplate` or a Cassandra `CqlSession` instance as you would with any other Spring Bean.
|
||||
The `spring.data.cassandra.*` properties can be used to customize the connection.
|
||||
The `spring.cassandra.*` properties can be used to customize the connection.
|
||||
Generally, you provide `keyspace-name` and `contact-points` as well the local datacenter name, as shown in the following example:
|
||||
|
||||
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
|
||||
----
|
||||
spring:
|
||||
data:
|
||||
cassandra:
|
||||
keyspace-name: "mykeyspace"
|
||||
contact-points: "cassandrahost1:9042,cassandrahost2:9042"
|
||||
local-datacenter: "datacenter1"
|
||||
cassandra:
|
||||
keyspace-name: "mykeyspace"
|
||||
contact-points: "cassandrahost1:9042,cassandrahost2:9042"
|
||||
local-datacenter: "datacenter1"
|
||||
----
|
||||
|
||||
If the port is the same for all your contact points you can use a shortcut and only specify the host names, as shown in the following example:
|
||||
@@ -344,22 +343,21 @@ If the port is the same for all your contact points you can use a shortcut and o
|
||||
[source,yaml,indent=0,subs="verbatim",configprops,configblocks]
|
||||
----
|
||||
spring:
|
||||
data:
|
||||
cassandra:
|
||||
keyspace-name: "mykeyspace"
|
||||
contact-points: "cassandrahost1,cassandrahost2"
|
||||
local-datacenter: "datacenter1"
|
||||
cassandra:
|
||||
keyspace-name: "mykeyspace"
|
||||
contact-points: "cassandrahost1,cassandrahost2"
|
||||
local-datacenter: "datacenter1"
|
||||
----
|
||||
|
||||
TIP: Those two examples are identical as the port default to `9042`.
|
||||
If you need to configure the port, use `spring.data.cassandra.port`.
|
||||
If you need to configure the port, use `spring.cassandra.port`.
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
The Cassandra driver has its own configuration infrastructure that loads an `application.conf` at the root of the classpath.
|
||||
|
||||
Spring Boot does not look for such a file by default but can load one using `spring.data.cassandra.config`.
|
||||
If a property is both present in `+spring.data.cassandra.*+` and the configuration file, the value in `+spring.data.cassandra.*+` takes precedence.
|
||||
Spring Boot does not look for such a file by default but can load one using `spring.cassandra.config`.
|
||||
If a property is both present in `+spring.cassandra.*+` and the configuration file, the value in `+spring.cassandra.*+` takes precedence.
|
||||
|
||||
For more advanced driver customizations, you can register an arbitrary number of beans that implement `DriverConfigLoaderBuilderCustomizer`.
|
||||
The `CqlSession` can be customized with a bean of type `CqlSessionBuilderCustomizer`.
|
||||
|
||||
Reference in New Issue
Block a user