如何解决dropwizard配置文件中的此错误



我在使用时运行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应用程序连接到hibernate。

请查看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

在我的案例中,我有一个由fatjar插件生成的dropwizard的应用程序jar,因此它看不到jar之外的文件。当我把我的config.yml放在项目中的resources目录中并再次编译应用程序时,它可以找到该文件。

最新更新