gpt4 book ai didi

java - Dropwizard for Hibernate 中的 SQLite 方言

转载 作者:行者123 更新时间:2023-12-01 13:36:33 25 4
gpt4 key购买 nike

我正在使用 dropwizard 和 SQLight 作为 hibernate 的数据库,为裁缝系统创建一个项目作为 RESTful Web 服务。问题是 hibernate 没有 SQLight 的方言,因此通过搜索获得了 SQLightDialect 的类代码。

现在我必须添加 SQLightDialect 类供 hibernate 使用,但不知道如何在 dropwizard 中执行此操作。

请帮忙。

最佳答案

通过添加解决

Map<String,String> s=new HashMap<String, String>();
s.put("hibernate.dialect","Hibernate.SQLightDialect.SQLiteDialect");
dbconfigurations.setProperties(s);

public class databaseConfiguration extends Configuration {

@Valid
@NotNull
@JsonProperty
DatabaseConfiguration dbconfigurations = new DatabaseConfiguration();

public DatabaseConfiguration getDatabaseConfiguration() {
//return dbconfigurations;
Map<String,String> s=new HashMap<String,String>();
s.put("hibernate.dialect","Hibernate.SQLightDialect.SQLiteDialect");
dbconfigurations.setProperties(s);
return dbconfigurations;
}
}

另一个解决方案请阅读 Web将其添加到 yml 文件中,例如:

database:
# the name of your JDBC driver
driverClass: org.postgresql.Driver
# the username
user: username
# the password
password: password
# the JDBC URL
url: jdbc:postgresql://localhost:5432/gis_database
properties:
hibernate.dialect: org.hibernate.spatial.dialect.postgis.PostgisDialect

关于java - Dropwizard for Hibernate 中的 SQLite 方言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21230220/

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