*无法识别的字段位于:数据库您的意思是::-指标-服务器-日志记录-DROPWIZARD [英] * Unrecognized field at: database Did you mean?: - metrics - server - logging - DROPWIZARD

查看:180
本文介绍了*无法识别的字段位于:数据库您的意思是::-指标-服务器-日志记录-DROPWIZARD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序配置文件(server.yml)中添加数据库详细信息之后,我无法启动我的dropwizard应用程序.

I cannot start my dropwizard application after add database details in my application configuration file (server.yml).

server.yml(应用程序配置文件)

server:
  applicationConnectors:
  - type: http 
    port: 8080
  adminConnectors:
  - type: http
    port: 9001

database:
  # the name of your JDBC driver
  driverClass: org.postgresql.Driver

  # the username
  user: dbuser

  # the password
  password: pw123

  # the JDBC URL
  url: jdbc:postgresql://localhost/database

  # any properties specific to your JDBC driver:
  properties:
    charSet: UTF-8

  # the maximum amount of time to wait on an empty pool before throwing an exception
  maxWaitForConnection: 1s

  # the SQL query to run when validating a connection's liveness
  validationQuery: "/* MyService Health Check */ SELECT 1"

  # the timeout before a connection validation queries fail
  validationQueryTimeout: 3s

  # the minimum number of connections to keep open
  minSize: 8

  # the maximum number of connections to keep open
  maxSize: 32

  # whether or not idle connections should be validated
  checkConnectionWhileIdle: false

  # the amount of time to sleep between runs of the idle connection validation, abandoned cleaner and idle pool resizing
  evictionInterval: 10s

  # the minimum amount of time an connection must sit idle in the pool before it is eligible for eviction
  minIdleTime: 1 minute

运行dropwizard应用程序的结果是,我可以看到:

As result of run dropwizard application I can see:

has an error:
  * Unrecognized field at: database
    Did you mean?:
      - metrics
      - server
      - logging

推荐答案

除了dropwizard示例给出的代码外,您还需要添加数据库属性的设置器.

In addition to code given by dropwizard example you need to add a setter for database property.

@Valid
@NotNull
@JsonProperty("database")
private DataSourceFactory database = new DataSourceFactory();

public DataSourceFactory getDataSourceFactory() {
    return database;
}

public void setDatabase(DataSourceFactory database) {
    this.database = database;
}

这篇关于*无法识别的字段位于:数据库您的意思是::-指标-服务器-日志记录-DROPWIZARD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆