简体   繁体   中英

Datastax Java driver 4.6.1 unable to override configurations with application.conf

I have created application.conf in my src.main.resources folder:

datastax-java-driver {
  basic {
    request {
      default-idempotence = true
      timeout = 5
    }
  }
  advanced {
    connection {
      max-requests-per-connection = 32767
    }
  }
}

These are just some test properties, and I don't think these properties are being applied because when I poke around in the debugger the defaults are unchanged.

Any ideas what could be going on or how I can check if the custom properties are being applied?

If you use Maven then you've placed it correctly in the src/main/resources folder. Otherwise, it needs to go in the application classpath.

@ThatHansel,

Could you show the output similar to the below to understand what values you get from your program?

I've a sample class leveraging DataStax Java Driver 4.9.0 and I am printing the values. I am using the defaults here for this demonstration.

import java.net.InetSocketAddress;

import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;

public class DriverConfigsDemo {
    public static void main(String... args) {
    try (CqlSession session = CqlSession.builder().addContactPoint(new InetSocketAddress("localhost", 9042))
        .withLocalDatacenter("dc1").build()) {// update to match your environment
        System.out.println("Driver Configs - Idempotence: " + session.getContext().getConfig().getDefaultProfile().getString(DefaultDriverOption.REQUEST_DEFAULT_IDEMPOTENCE));
        System.out.println("Driver Configs -     Timeout: " + session.getContext().getConfig().getDefaultProfile().getDuration(DefaultDriverOption.REQUEST_TIMEOUT));
    }
    }
}

and when I run this program I get the below and you should also see something similar in your case (ie idempotence being true & timeout being PT5S ),

09:56:10.019 [main] INFO  c.d.o.d.i.c.DefaultMavenCoordinates - DataStax Java driver for Apache Cassandra(R) (com.datastax.oss:java-driver-core) version 4.9.0
09:56:10.574 [s0-admin-0] INFO  c.d.o.d.internal.core.time.Clock - Using native clock for microsecond precision
Driver Configs - Idempotence: false
Driver Configs -     Timeout: PT2S

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM