springboot+jpa动态指定schema

springboot+jpa动态指定schema,第1张

jpa根据实体类创建数据库表时,@Table(schema=""),schema默认是"",可以通过该属性指定schema,但是在开发或者生产环境下可能需要切换schema,总不能去每个实体类上一一修改schema属性的值,可以在springboot的配置文件中增加如下配置,实现动态指定schema,而无需在实体类上加schema

spring.datasource.url=jdbc:postgresql://x.x.x.x:xxxx/databasename?currentSchema=XXXX

spring.jpa.properties.hibernate.default_schema=XXXX

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/887128.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-14
下一篇 2022-05-14

发表评论

登录后才能评论

评论列表(0条)

保存