springboot整合postgresql_springboot 整合druid,使用postgresql

1.首先引入相关依赖

com.alibaba

druid-spring-boot-starter

1.1.10

org.postgresql

postgresql

runtime

org.springframework.boot

spring-boot-starter-jdbc

2.配置yml

spring:

datasource:

druid:

driver-class-name: org.postgresql.Driver

url: jdbc:postgresql://ip:port/**?&ssl=false

username: postgres

password: 123456

initial-size: 1

max-active: 128

min-idle: 96

filter:

stat:

log-slow-sql: true

db-type: postgresql

enabled: true

3.配置类

@Slf4j

@Configuration

public class DruidConfig {

@ConfigurationProperties(prefix = "spring.datasource.druid")

@Bean(destroyMethod = "close", initMethod = "init") //第一次使用,页面会出现(*) property for user to setup

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PGSQL是指PostgreSQL,它是一种强大的关系型数据库管理系统。在使用Spring Boot框架搭建PGSQL的应用时,常见的做法是使用Druid作为连接池,MyBatis作为持久层框架,通过MyBatis Generator自动生成POJO、Mapper和DAO代码。 在Spring Boot的配置文件中,需要导入PGSQL的依赖项并配置数据源信息,例如URL、用户名、密码等。可以使用以下代码片段作为yml配置文件的示例: ```yaml spring: datasource: url: jdbc:postgresql://localhost:5432/postgres username: postgres password: 123456 driverClassName: org.postgresql.Driver ``` 此外,还可以配置其他相关的属性,如Jackson的时区、JPA的设置、Hibernate的配置、数据库的DDL操作等。需要注意的是,以上仅为一个示例配置,根据实际情况可能需要做出相应的调整。 关于安装PGSQL的方式,可以通过Stack Builder进行安装,但有时可能会遇到速度慢或卡顿的情况。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [springboot+mybatis3+druid+postgresql](https://download.csdn.net/download/qq_35918388/10399737)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Postgresql+Springboot yml基本使用](https://blog.csdn.net/qq_39898191/article/details/108797167)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [Spring Boot配合Postgresql和MybatisPlus实现外卖平台常见的距离你xxx米功能](https://blog.csdn.net/tsgjcnyn/article/details/127694116)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值