开源项目 – RuoYi-Cloud集成PostgreSQL数据库

导读:本篇文章讲解 开源项目 – RuoYi-Cloud集成PostgreSQL数据库,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

1、创建数据库

执行ry-cloud-postgreSQL脚本

原文地址(持续更新)

sql/postgresql.sql · Listen/RuoYi-Vue-Postgresql – Gitee.com

2、在Nacos中修改yml的相应的参数

涉及配置文件

  1. ruoyi-job-dev.yml
  2. ruoyi-system-dev.yml
  3. ruoyi-gen-dev.yml

开源项目 - RuoYi-Cloud集成PostgreSQL数据库

validationQuery: SELECT 1 

driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: postgres
password: postgres

3、代码修改

提示:只修改ruoyi-system目录下的内容即可

3.1 修改pom.xml文件,将mysql的依赖jar包替换成postgresql

涉及配置文件

  1. ruoyi-job-dev.yml
  2. ruoyi-system-dev.yml
  3. ruoyi-gen-dev.yml

开源项目 - RuoYi-Cloud集成PostgreSQL数据库

3.2 将SysMenuMapper.xml中的`query`改为query

3.3 全局替换项目中使用的ifnull函数为coalesce

因为postgresql数据库没有ifnull()函数。

注意只替换ifnull为coalesce,不带括号。

开源项目 - RuoYi-Cloud集成PostgreSQL数据库

3.4 全局替换Mapper中 status = 0 为 status = ‘0’

3.5 全局替换Mapper中sysdate()为now()

因为postgresql数据库没有sysdate()函数

开源项目 - RuoYi-Cloud集成PostgreSQL数据库

3.6 全局替换Mapper中find_in_set(#{deptId}, ancestors)为cast(#{deptId} as varchar) = any(string_to_array(ancestors,’,’))

部门查询SQL中使用到的find_in_set函数

3.7 修改ScheduleConfig,添加自动任务依赖

//pg启用特殊配置,否则会报错  update by wuzuhu on 20181224
prop.put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.PostgreSQLDelegate");

开源项目 - RuoYi-Cloud集成PostgreSQL数据库

3.8 替换Mapper中date_format

  • 全局替换date_format(#{params.beginTime},’%y%m%d’)替换成 to_timestamp(#{params.beginTime}, ‘YYYY-mm-dd’)
  • 全局替换date_format(#{params.endTime},’%y%m%d’)替换成 to_timestamp(#{params.endTime}, ‘YYYY-mm-dd’)
  • 全局替换date_format(替换成 to_timestamp(to_char(
  • 全局替换,’%y%m%d’)替换成,’YYYY-mm-dd’), ‘YYYY-mm-dd’)

替换前

开源项目 - RuoYi-Cloud集成PostgreSQL数据库

替换后

开源项目 - RuoYi-Cloud集成PostgreSQL数据库

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/117224.html

(0)
seven_的头像seven_bm

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!