簡體   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