gpt4 book ai didi

java - Maven Dropwizard 中的 Hibernate 数据库连接错误

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:26:01 25 4
gpt4 key购买 nike

我一直在尝试使用 Maven 的 Dropwizard 项目。我可以运行 Hello World 程序。当我尝试使用 Hibernate 运行数据库程序时,使用 java -jar 运行程序时出现如下错误。

default configuration has the following errors:   
* database.driverClass may not be null (was null)
* database.url may not be null (was null)
* database.user may not be null (was null)
* template may not be empty (was null)

这是我的 hello-world.yml 文件

template: Hello, %s!
defaultName: Stranger
database:
driverClass: com.mysql.jdbc.Driver
user: root
password:
url: jdbc:mysql://localhost/test

提前致谢!!

最佳答案

Dropwizard repository 中的一些示例所述,您可能需要提供模板文件配置,以便从那里提取数据库属性。

那么您是否尝试运行您的应用程序以使用 .yml 文件作为命令行参数来设置您的数据库?类似于以下内容:

java -jar your-artifact.jar db migrate your-configuration-file.yml

然后按如下方式运行您的应用程序:

java -jar your-artifact.jar server your-configuration-file.yml

关于java - Maven Dropwizard 中的 Hibernate 数据库连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25480442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com