Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Dropwizard YAML文件中无法识别的字段_Java_Dropwizard - Fatal编程技术网

Java Dropwizard YAML文件中无法识别的字段

Java Dropwizard YAML文件中无法识别的字段,java,dropwizard,Java,Dropwizard,我在启动Dropwizard应用程序时遇到以下错误,该应用程序使用到MySQL的数据库连接: app.yaml has an error: * Unrecognized field at: database Did you mean?: - metrics - instanceId - logging - server - statsConfig [12 more] 在Dropwizard配置文件的末尾,我有以下内容: database:

我在启动Dropwizard应用程序时遇到以下错误,该应用程序使用到MySQL的数据库连接:

app.yaml has an error:
* Unrecognized field at: database
  Did you mean?:
    - metrics
    - instanceId
    - logging
    - server
    - statsConfig
      [12 more]
在Dropwizard配置文件的末尾,我有以下内容:

database:
  driverClass: com.mysql.jdbc.Driver
  user: ${MYSQL_USERNAME}
  password: ${MYSQL_PASSWORD}
  url: ${MYSQL_URL}
@Valid()
@NotNull()
@JsonProperty()
private static DataSourceFactory database;

public static DataSourceFactory getDatabase() {
  return database;
}

public static void setDatabase(final DataSourceFactory database) {
  AppConfig.database = database;
}
在我的配置类中,我有以下内容:

database:
  driverClass: com.mysql.jdbc.Driver
  user: ${MYSQL_USERNAME}
  password: ${MYSQL_PASSWORD}
  url: ${MYSQL_URL}
@Valid()
@NotNull()
@JsonProperty()
private static DataSourceFactory database;

public static DataSourceFactory getDatabase() {
  return database;
}

public static void setDatabase(final DataSourceFactory database) {
  AppConfig.database = database;
}
其他几个复杂的配置对象正在正确加载(这是一个相当大的配置文件),但这一个不是。知道我为什么会犯这个错误吗


编辑此问题与此问题类似:。但是,该解决方案对我不起作用。

编辑:检查示例应用程序,然后重试

  • @JsonProperty()
    -这里有额外的括号
  • 私有静态数据源工厂数据库-从此处删除
    静态
    。参考以获取其外观示例
  • 还添加
    =newdatasourcefactory()根据文档和
  • 我已经检查了旧版本的
    Dropwizard
    ,第二个问题是最直接的问题