java - 为什么我的应用程序总是连接到“公共”模式?
问题描述
我正在尝试使用 springboot+jpa 连接到 postgres 数据库
postgres 在数据库中有两个模式
public
ratings
评级模式具有表 food_ratings
即使我尝试了以下被广泛建议的方法,默认模式总是被选择为公共而不是评级模式
-> 在应用程序属性中显式设置默认模式
spring.jpa.properties.hibernate.default_schema=ratings
->在实体中明确将模式设置为评级
@Getter
@Setter
@Entity
@Table(name = "food_ratings", schema = "ratings")
public class FoodRatings implements Serializable {
@Id
@Column(name = "id")
private String id;
@Column(name="description")
String description;
}
我最终得到错误
org.postgresql.util.PSQLException: ERROR: relation "food_ratings" does not exist
注意:我在代码和数据库中都使用小写的模式名和表名。我在这里还缺少什么其他选择?
解决方案
问题出在 postgres 驱动程序版本上。我使用的是 9.x 版本。
将其升级到 42.0.0 使其工作。
推荐阅读
- javascript - 无法获取未定义或空引用的属性“classList” - 在第一次 MouseClick
- entity-framework - 指定的 deps.json 不存在
- shopware - 在导致崩溃的模型事件中调用 flush()
- javascript - 样式化自定义导入的 vue 组件
- laravel - 如何将存储在 Laravel Voyager 中的视频作为文件显示在前端?
- flutter - Flutter:在 Mock 中模拟流时提供程序错误
- bootstrap-4 - 如何在 Angular 材料 8 中连续平均分割两个 mat-form-fields?
- cmake - 从 .mk 迁移到 CMakeList
- php - 在订单表 laravel 上保存购物车详细信息
- c++ - 与 fftw3 相比,错误的 2D CuFFT 逆变换