在使用时运行jar时出现以下错误:
java -jar <jarPath>.jar server config.yml
错误:
* Configuration at config.yml must not be empty
at io.dropwizard.configuration.ConfigurationParsingException$Builder.build(ConfigurationParsingException.java:279)
at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:85)
at io.dropwizard.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:126)
at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:74)
at io.dropwizard.cli.Cli.run(Cli.java:79)
at io.dropwizard.Application.run(Application.java:94)
at com.flipkart.cx.taggingconsole.webapp.application.DataConsoleApp.main(DataConsoleApp.java:62)
这是我的配置文件,对于这一切我还是很陌生,并尝试使用config.yml而不是hibernate.cfg.xml将dropwizard应用程序连接到休眠状态。
请查看config.yml文件
server:
applicationConnectors:
- type: http
port: 8800
adminConnectors:
- type: http
port: 9800
# Database settings.
database:
# the name of your JDBC driver
driverClass: com.mysql.jdbc.Driver
# the username
user: root
# the password
password: root1234
# the JDBC URL
url: jdbc:h2:./target/example
properties:
hibernate.dialect: org.hibernate.dialect.MySQLDialect
hibernate.connection.url: jdbc:mysql://localhost/test
hibernate.connection.driver_class: com.mysql.jdbc.Driver
hibernate.show_sql: false
hibernate.generate_statistics: false
hibernate.hbm2ddl.auto: update # validates schema when service is started
hibernate.current_session_context_class: thread
答案 0 :(得分:0)
就我而言,我有一个由fatjar插件生成的dropwizard的应用jar,因此无法在jar之外看到该文件。当我将public class Account {
public int phoneNumber;
public String customerName;
public Account(int phoneNumber) {
this.phoneNumber = phoneNumber;
this.customerName = phoneNumber != 0 ? String.valueOf(phoneNumber) : "No INFO";
}
public int getPhoneNumber() {
return phoneNumber;
}
public String getCustomerName() {
return customerName;
}
}
放入项目中的资源目录并再次编译应用程序时,它可以找到该文件。