繁体   English   中英

Datastax Java 驱动程序 4.6.1 无法使用 application.conf 覆盖配置

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

我在 src.main.resources 文件夹中创建了 application.conf:

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

这些只是一些测试属性,我认为没有应用这些属性,因为当我在调试器中浏览时,默认值没有改变。

任何想法可能会发生什么或者我如何检查是否正在应用自定义属性?

如果您使用 Maven,那么您已将其正确放置在src/main/resources文件夹中。 否则,它需要进入应用程序类路径。

@ThatHansel,

您能否显示类似于以下内容的输出以了解您从程序中获得的值?

我有一个利用 DataStax Java Driver 4.9.0的示例类,我正在打印这些值。 我在此演示中使用默认值。

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));
    }
    }
}

当我运行这个程序时,我得到下面的结果,你也应该在你的情况下看到类似的东西(即幂等性为,超时为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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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