Postgresql+Springboot yml基本使用

news/2024/7/9 22:19:18 标签: 数据库, postgresql, mysql

一、Postgresql介绍

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

1.、 PostgostreSQL 稳定性很强,在崩溃等场景下抗打击能力特别强,对比mysql在电脑崩溃等情景下的丢失数据情况,PG数据库这方面要好一些。

2.、对比Mysql,PostgostreSQL支持的数据类型更多

3.、PostgostreSQL可以使用sql进行编程

4.、PG 的有多种集群架构可以选择,plproxy 可以支持语句级的镜像或分片,slony 可以进行字段级的同步设置,standby 可以构建WAL文件级或流式的读写分离集群,同步频率和集群策略调整方便,操作非常简单。

5.、PostgreSQL的可以使用函数和条件索引

6.、PG 的 TEXT 类型可以直接访问,SQL语法内置正则表达式,能够索引,还可以全文检索。用PG的话,文档数据库都可以省了。

7.、 PostgreSQL的性能很强,在高并发读写的场景下,PostgreSQL的性能指标依旧可以维持顶峰,相对比 MySQL 在同样的场景下会出现一个明显的下滑(mysql5.5之后,在企业级版本中有个插件可以改善很多,不过需要付费)。

二、Postgresql+Springboot yml基本使用

1.导入Maven

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>

复制

2.编写yml配置文件

spring:
  datasource:

    url: jdbc:postgresql://localhost:5432/postgres # url: jdbc:mysql://localhost:3306/tis?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false
    username: postgres
    password: 123456
    driverClassName: org.postgresql.Driver
  jackson:
    time-zone: GMT+8
  jpa:
    properties:
      open-in-view: true
      hibernate:
        show_sql: false
        format_sql: true
        dialect: org.hibernate.dialect.PostgreSQLDialect
        temp:
          use_jdbc_metadata_defaults: false
        hbm2ddl:
          auto: update
    database: postgresql

  rabbitmq:
    host: 192.168.90.205
    port: 5672
    username: admin
    password: admin
    virtual-host: /

复制

3.编写Entity实体类

package com.supcon.oms.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
/**
* @author: zhaoxu
* @date: 2020/9/8 20:43
*/
@Data
@Entity
@Table(name = "t_tank", schema = "public", catalog = "")
@JsonIgnoreProperties(ignoreUnknown = true)
public class TTankEntity implements Serializable { 

private static final long serialVersionUID = 4718371560086576837L;
@Id
@Column(name="tank_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer tankId;
@Basic
@Column(name = "tank_no", nullable = false, length = 255)
private String tankNo;
@Basic
@Column(name = "equipment_type", nullable = true, length = 255)
private String equipmentType;
@Basic
@Column(name = "tank_name", nullable = true, length = 255)
private String tankName;
@Basic
@Column(name = "tank_description", nullable = true, length = 1000)
private String tankDescription;
@Basic
@Column(name = "equipment_status", nullable = true, length = 255)
private String equipmentStatus;
@Basic
@Column(name = "tank_keepwarm", nullable = true, length = 100)
private String tankKeepwarm;
@Basic
@Column(name = "tank_status", nullable = true, length = 255)
private String tankStatus;
@Basic
@Column(name = "tank_farmid", nullable = true, length = 255)
private String tankFarmid;
@Basic
@Column(name = "tank_type", nullable = true, length = 255)
private String tankType;
@Basic
@Column(name = "tank_diameter", nullable = true, precision = 0)
private Double tankDiameter;
@Basic
@Column(name = "tank_height", nullable = true, precision = 0)
private Double tankHeight;
@Basic
@Column(name = "tank_capacity_standard", nullable = true, precision = 0)
private Double tankCapacityStandard;
@Basic
@Column(name = "liquid_level_temperature", nullable = true, precision = 0)
private Double liquidLevelTemperature;
@Basic
@Column(name = "tank_capacity_safe", nullable = true, precision = 0)
private Double tankCapacitySafe;
@Basic
@Column(name = "calculate_type", nullable = true, length = 255)
private String calculateType;
@Basic
@Column(name = "working_level_min", nullable = true, precision = 0)
private Double workingLevelMin;
@Basic
@Column(name = "working_level_max", nullable = true, precision = 0)
private Double workingLevelMax;    @Basic
@Column(name = "nominal_volume", nullable = true, precision = 0)
private Double nominalVolume;
@Basic
@Column(name = "thermal_expansion_system", nullable = true, length = 255)
private String thermalExpansionSystem;
@Basic
@Column(name = "floating_point_quality", nullable = true, length = 255)
private String floatingPointQuality;
@Basic
@Column(name = "level_change_dead", nullable = true, length = 100)
private String levelChangeDead;
@Basic
@Column(name = "alarm_events", nullable = true, length = 255)
private String alarmEvents;
@Basic
@Column(name = "tank_capacity_now", nullable = true, precision = 0)
private Double tankCapacityNow;
@Basic
@Column(name = "tank_quality", nullable = true, precision = 0)
private Double tankQuality;
@Basic
@Column(name = "tank_temperature", nullable = true, precision = 0)
private Double tankTemperature;
@Basic
@Column(name = "tank_pressure", nullable = true, precision = 0)
private Double tankPressure;
@Basic
@Column(name = "flow_speed", nullable = true, precision = 0)
private Double flowSpeed;
@Basic
@Column(name = "flow_amount", nullable = true, precision = 0)
private Double flowAmount;
@Basic
@Column(name = "remaining_space", nullable = true, precision = 0)
private Double remainingSpace;
@Basic
@Column(name = "vcf", nullable = true, precision = 0)
private Double vcf;
@Basic
@Column(name = "liquid_level_status", nullable = true, length = 255)
private String liquidLevelStatus;
@Basic
@Column(name = "net_standard_volume", nullable = true, precision = 0)
private Double netStandardVolume;
@Basic
@Column(name = "water_bottom_volume", nullable = true, precision = 0)
private Double waterBottomVolume;
@Basic
@Column(name = "tank_flow_inout", nullable = true, precision = 0)
private Double tankFlowInout;
@Basic
@Column(name = "usable_volume", nullable = true, precision = 0)
private Double usableVolume;
@Basic
@Column(name = "standard_quality_sum", nullable = true, precision = 0)
private Double standardQualitySum;
@Basic
@Column(name = "standard_quality_net", nullable = true, precision = 0)
private Double standardQualityNet;
@Basic
@Column(name = "working_volume_max", nullable = true, precision = 0)
private Double workingVolumeMax;
@Basic
@Column(name = "working_volume_min", nullable = true, precision = 0)
private Double workingVolumeMin;
@Basic
@Column(name = "liquid_level", nullable = true, precision = 0)
private Double liquidLevel;
@Basic
@Column(name = "physical_temperature", nullable = true, precision = 0)
private Double physicalTemperature;
@Basic
@Column(name = "ambient_temperature", nullable = true, precision = 0)
private Double ambientTemperature;
@Basic
@Column(name = "density_of_material", nullable = true, precision = 0)
private Double densityOfMaterial;
@Basic
@Column(name = "police_liquid_level", nullable = true, length = 255)
private String policeLiquidLevel;
@Basic
@Column(name = "police_temperature", nullable = true, length = 255)
private String policeTemperature;
@Basic
@Column(name = "police_liquid_switch", nullable = true, length = 255)
private String policeLiquidSwitch;
@Basic
@Column(name = "police_instrument_system", nullable = true, length = 255)
private String policeInstrumentSystem;
@Basic
@Column(name = "police_inout_volume", nullable = true, length = 255)
private String policeInoutVolume;
@Basic
@Column(name = "oms_source_target", nullable = true)
private Integer omsSourceTarget;
@Basic
@Column(name = "oms_share", nullable = true)
private Integer omsShare;
@Basic
@Column(name = "oms_share_depth", nullable = true)
private Integer omsShareDepth;
@Basic
@Column(name = "oms_occupy", nullable = true)
private Integer omsOccupy;
@Basic
@Column(name = "materiel_name", nullable = true, length = 255)
private String materielName;
@Basic
@Column(name = "materiel_type", nullable = true, length = 255)
private String materielType;
@Basic
@Column(name = "materiel_quality_attributes", nullable = true, length = 255)
private String materielQualityAttributes;
@Basic
@Column(name = "materiel_density", nullable = true, precision = 0)
private Double materielDensity;
}

复制

其他的按照正常的框架写就可以了,和mysql的使用方式基本上没有区别


http://www.niftyadmin.cn/n/287998.html

相关文章

【Linux网络】网络应用层的 http 和 https协议

文章目录 1、http协议1.1 认识URL1.2 http协议格式1.3 http的方法&#xff08;GET和POST&#xff09;1.4 状态码1.5 cookie1.6 短连接和长连接 2、https协议2.1 常见的加密方式2.2 探究https协议的加密2.3 CA证书 1、http协议 在之前学习序列化和反序列化的时候&#xff0c;认…

净利润下滑13%,帅丰电器已掉队?

近年来&#xff0c;随着市场竞争加剧&#xff0c;厨电行业加速洗牌&#xff0c;超60%杂牌或被淘汰出局&#xff0c;三类品牌全部被清退。而作为毛利最高的厨电细分市场&#xff0c;集成灶行业吸引了大批企业涌入&#xff0c;市场渗透率快速提升&#xff0c;已经超过30%&#xf…

YOLOv5:添加SE、CBAM、CoordAtt、ECA注意力机制

YOLOv5&#xff1a;添加SE、CBAM、CoordAtt、ECA注意力机制 前言前提条件相关介绍注意力机制SE添加SE注意力机制到YOLOv5 CBAM添加CBAM注意力机制到YOLOv5 CoordAtt添加CoordAtt注意力机制到YOLOv5 ECA添加ECA注意力机制到YOLOv5 参考 前言 记录在YOLOv5添加注意力机制&#xf…

【OpenCV】 2D-2D:对极几何算法原理

2D-2D匹配: 对极几何 SLAM十四讲笔记1 1.1 对极几何數學模型 考虑从两张图像上观测到了同一个3D点&#xff0c;如图所示**。**我们希望可以求解相机两个时刻的运动 R , t R,t R,t。 假设我们要求取两帧图像 I 1 , I 2 I_1,I_2 I1​,I2​之间的运动,设第一帧到第二帧的运动为…

mxf文件格式详解

MXF是英文Material eXchange Format&#xff08;素材交换格式&#xff09;的缩语。MXF是SMPTE&#xff08;美国电影与电视工程师学会&#xff09;组织定义的一种专业音视频媒体文件格式。MXF主要应用于影视行业媒体制作、编辑、发行和存储等环节。SMPTE381M&#xff08;把MPEG格…

Java设计模式-建造者模式

简介 建造者模式是一种创建型设计模式&#xff0c;用于将复杂对象的构建过程与其表示分离&#xff0c;使得同样的构建过程可以创建不同的表示。建造者模式通过将复杂对象的构建过程分解为多个简单的步骤来实现。 与其他创建型模式不同&#xff0c;建造者模式强调的是将构建过…

数控新代系统解锁解密 数控机床车床使用期限破解

时效性保证了良好的用户体验&#xff0c;根据经验在交易环节&#xff0c;延迟越低转化效果也会越好。传统的直播延迟问题已经成为了一个不容忽视的问题&#xff0c;高延迟不仅破坏了用户的观看体验&#xff0c;也让主播难以实时获取到用户的反馈。为了进一步优化直播时效体验&a…

09 虚拟机配置-虚拟机描述

文章目录 09 虚拟机配置-虚拟机描述9.1 概述9.2 元素介绍9.3 配置示例 09 虚拟机配置-虚拟机描述 9.1 概述 本节介绍虚拟机domain根元素和虚拟机名称的配置。 9.2 元素介绍 domain&#xff1a;虚拟机XML配置文件的根元素&#xff0c;用于配置运行此虚拟机的hypervisor的类型…