SpringBoot 连接 PostgreSQL 使用指定 模式(Schema) 的 yml配置

目录

1 PostgreSQL 介绍

2 SpringBoot连接PostgreSQL的配置

2.1 相关依赖(pom.xml)

2.2 yml配置

2.2.1 不指定schema的情况下,使用公共的schema

2.2.2 指定schema的情况下


PostgreSQL介绍

        PostgreSQL是一种特性非常齐全的自由软件的对象-关系型数据库管理系统(ORDBMS),是以加州大学计算机系开发的POSTGRES,4.2版本为基础的对象关系型数据库管理系统。POSTGRES的许多领先概念只是在比较迟的时候才出现在商业网站数据库中。PostgreSQL支持大部分的SQL标准并且提供了很多其他现代特性,如复杂查询、外键触发器视图、事务完整性、多版本并发控制等。同样,PostgreSQL也可以用许多方法扩展,例如通过增加新的数据类型、函数、操作符、聚集函数、索引方法、过程语言等。另外,因为许可证的灵活,任何人都可以以任何目的免费使用、修改和分发PostgreSQL。

2 SpringBoot连接PostgreSQL的配置

2.1 相关依赖(pom.xml)

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.3.3</version>
    <scope>runtime</scope>
</dependency>

2.2 yml配置

2.2.1 不指定schema的情况下,使用公共的schema

spring:
  datasource:
    driver-class-name: org.postgresql.Driver
    url: jdbc:postgresql://localhost:5432/database
    username: xxx
    password: xxx

2.2.2 指定schema的情况下

spring:
  datasource:
    driver-class-name: org.postgresql.Driver
    url: jdbc:postgresql://localhost:5432/database?currentSchema=schema
    username: xxx
    password: xxx

猜你喜欢

转载自blog.csdn.net/weixin_48568302/article/details/126894740
今日推荐