ken4ward avatar image
ken4ward asked Erick Ramirez answered

How do I set the local DC in my Spring boot application?

I have been dealing with this for the past 36 hours, and yet to resolve it. I added Cassandra to the Spring boot application I'm working on. The configuration of the app is as follows:

Spring boot 2.4.5, Cassandra-3.11. After much effort I followed the instruction given to add this file in the resource folder of the app - application.conf as suggested, yet the error continue to happen


// Add `application.conf` to your classpath with the following contents:
datastax-java-driver {
  basic {
    contact-points = [ ""]
    load-balancing-policy.local-datacenter = datacenter1

Spring boot dependency


This is my spring boot properties for Cassandra
load-balancing-policy.local-datacenter = datacenter1

This is the crux of the error

Since you provided explicit contact points, the local DC must be explicitly set (see basic.load-balancing-policy.local-datacenter in the config, or set it programmatically with SessionBuilder.withLocalDatacenter). Current contact points are: Node(endPoint=/, hostId=c762a627-1a89-4fc0-89dc-0d8b8cccbee1, hashCode=4c83b585)=datacenter1. Current DCs in this cluster are: datacenter1

With all of the implementation of the suggested actions, nothing happened, the error continued to occur. And it seems the properties.conf file isn't picked up at all.

Please, help out. Much time has been wasted on this simple thing already. Thanks a lot.

10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

With Spring Boot, you need to set the properties either in the file, application.yml file or as command-line switches. Spring Boot does not use application.conf.

As you stated, the configuration isn't getting picked up by your application so I suspect that the configuration file is not in the correct location. If you're using the properties file, make sure that it is located in:


To avoid conflicts, make sure that you only have the properties file and remove all other files like application.yml or application.conf.

When you load the application, check the classpath to make sure that the resources/ directory is included. Cheers!

10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.