> 文章列表 > SpringBoot 连接 PostgreSQL 查询指定模式(Schema)下的表数据

SpringBoot 连接 PostgreSQL 查询指定模式(Schema)下的表数据

SpringBoot 连接 PostgreSQL 查询指定模式(Schema)下的表数据

方法一:修改yml配置文件
spring:datasource:driver-class-name: org.postgresql.Driverurl: jdbc:postgresql://localhost:5432/database?currentSchema=你要查的表的模式username: xxxpassword: xxx
方法二:使用注解(推荐)
spring:datasource:driver-class-name: org.postgresql.Driverurl: jdbc:postgresql://localhost:5432/databaseusername: xxxpassword: xxx

然后在所需实体类上添加

@TableName("你要查的表的模式.你要查的表")

@TableName("你要查的表的模式.\\"表名有大写字母的表\\"")