I'm getting the following error when launching a Dropwizard application that uses a database connection to MySQL:
configuration.yml has an error:
* Unrecognized field at: driverClass
Did you mean?:
- database
- server
- metrics
- logging
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
Configuration.yml
is formatted properly according to the yaml specification . 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) PS You don't have to initialize datasourceFactory
via new DataSourceFactory();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.