[英]configuration.yml has an error: * Unrecognized field at: driverClass - DROPWIZARD
I'm getting the following error when launching a Dropwizard application that uses a database connection to MySQL: 启动使用数据库连接到MySQL的Dropwizard应用程序时出现以下错误:
configuration.yml has an error:
* Unrecognized field at: driverClass
Did you mean?:
- database
- server
- metrics
- logging
Configuration.yml: Configuration.yml:
server:
applicationConnectors:
- type: http
port: 9010
adminConnectors:
- type: http
port: 9011
database:
driverClass: com.mysql.jdbc.Driver
user: ppub_web
password: password
url: jdbc:mysql://url:to connect port
Configuration class: 配置类:
public class ConfigurationClass extends Configuration{
@Valid
@NotNull
@JsonProperty("database")
private DataSourceFactory datasourceFactory = new DataSourceFactory();
public DataSourceFactory getDataSourceFactory() {
return datasourceFactory;
}
}
DataSourceFactory
contains a field called driverClass
确保您的DataSourceFactory
类包含一个名为driverClass
的字段 Configuration.yml
is formatted properly according to the yaml specification . 确保根据yaml规范正确Configuration.yml
。 According to the error message, you have the problem exactly because of that. 根据错误消息,您正是因为此而有问题。 DataSourceFactory
are accessible to Jackson (getters/setters or public fields or right Jackson annotations for allowing setting private fields) 确保Jackson可以访问DataSourceFactory
中的字段(获取程序/设置程序或公共字段,或正确的Jackson批注,以允许设置私有字段) PS You don't have to initialize datasourceFactory
via new DataSourceFactory();
PS:您不必通过new DataSourceFactory();
初始化datasourceFactory
new DataSourceFactory();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.