【问题标题】:Failed to bind properties under 'cluster' to com.datastax.driver.core.Cluster无法将“集群”下的属性绑定到 com.datastax.driver.core.Cluster
【发布时间】:2018-12-18 16:44:20
【问题描述】:

运行 Spring Boot 应用程序时出现以下异常:

Failed to bind properties under 'cluster' to com.datastax.driver.core.Cluster:

    Property: cluster
    Value: 
    Origin: "cluster" from property source "class path resource [application.yml]"
    Reason: No converter found capable of converting from type [java.lang.String] to type [com.datastax.driver.core.Cluster]

Action:

Update your application's configuration

正在从 consul 读取配置文件。因此,从错误描述中可以看出,属性“cluster”的值是空的。但配置如文件所见,看起来像:

cassandra:
  host: abc:50126
  forceSchemaCreation: false
  cluster:
    name: test_cluster    
    user: test_user
    password: password    
    defaultFetchSize: 10000
    callback.executor.pool: 10
  • yml 文件中可能存在语法错误吗? 或者
  • 为什么错误提示“cluster”而不是“cassandra.cluster”?怀疑这部分是对的吗? 或者
  • 描述中的“Origin”部分指向“类路径资源 [application.yml]”。这应该是一个问题?

另外,因为我在运行应用程序时收到“Command line too long”消息,所以我在工作空间文件中将“dynamic.classpath”设置为 true。

【问题讨论】:

    标签: java maven spring-boot cassandra


    【解决方案1】:

    yml 文件中会不会有语法错误?
    我在 yml 文件中没有看到任何错误。

    为什么错误说 'cluster' 而不是 'cassandra.cluster'?
    描述中的 'Origin' 部分指向 'class path resource [application.yml] '。这应该是一个问题?
    请检查您是否在配置类上使用@ConfigurationProperties。如果是,请尝试删除它,如果不需要。只需 @Configuration 就可以自动装配 yml 中的所有全局属性。

    【讨论】:

    • 是的,删除了注释 ConfigurationProperties ,将它与 Configuration 一起使用。成功了!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-17
    • 1970-01-01
    • 2012-06-15
    • 2020-11-20
    • 1970-01-01
    • 2015-06-26
    • 2014-03-24
    相关资源
    最近更新 更多