* Unrecognized field at: database Did you mean?: - metrics - server - logging - DROPWIZARD

十年热恋 提交于 2019-12-05 07:47:04

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

In your application configuration java file, you have to add the matching property for "database". If the properties you're specifying are the standard ones (which they look to be, good!) then you can keep with the DataSourceFactory type:

public class ExampleConfiguration extends Configuration {
    @Valid
    @NotNull
    @JsonProperty
    private DataSourceFactory database = new DataSourceFactory();

    public DataSourceFactory getDataSourceFactory() {
        return database;
    }

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

Example here: http://www.dropwizard.io/0.9.0/docs/manual/jdbi.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!