Java driver configuration

When i try to use application.conf file in my spring boot application for customize e.g contact-points there is no effect. It seems that application.conf doesnt load…But if i use application.yaml with contact-points its work

java driver version 4.15.0
spring boot v3.1.2

application.conf in src/main/resources:
datastax-java-driver {
basic.contact-points = [10.72.63.81,10.72.63.82,10.72.63.83]
}

Hi Dmitry,

I don’t have experience with building Spring applications, so it’s hard for me to say what could be going wrong here without seeing the application. If my understanding is correct application.yml is a configuration file for the spring application and application.conf is the usual Typesafe config that should be picked up by the driver. It should be possible to pass driver configuration both ways, but using different formats.

First, it seems that the format you’re using for your application.conf is slightly wrong. Perhaps this is why the driver rejects those contact points. Each address should be of the “host:port” format.
Basically this:

datastax-java-driver {
basic.contact-points = ["192.168.1.2:9042","192.168.1.3:9042", "192.168.1.4:9042"]
}

I tried setting up example application with such application.conf and I’ve had no issues customizing the contact points. I’ve put it in src/main/resources too.
Another issue you may be facing is that one of the configs overwrites what another says. Make sure that you define contact points only in one of them and also not in any extra environment variables.

1 Like