建设学校网站的需求分析,建设工程合同在性质上属于,微博推广,网页模板下载不了xxl-job支持了mysql数据库#xff0c;其他的数据库适配得自己弄一下#xff0c;下面以目前最新的2.4.1为例进行说明适配postgresql数据库的过程。
获取源代码
从github或gitee获取源代码#xff0c;目前最新版本2.4.1
xxl官网#xff1a;分布式任务调度平台XXL-JOB
建立…xxl-job支持了mysql数据库其他的数据库适配得自己弄一下下面以目前最新的2.4.1为例进行说明适配postgresql数据库的过程。
获取源代码
从github或gitee获取源代码目前最新版本2.4.1
xxl官网分布式任务调度平台XXL-JOB
建立数据库
源代码的doc目录下有mysql建库脚本在mysql中利用脚本建立数据库
利用navicat的数据传输功能将mysql数据库导入到postgresql中 使用 Navicat 编辑器手动修改所有表的数字类型字段添加默认值 0。主键不用添加默认值。例如 int4 NOT NULL 类型为默认 0。 创建 PostgreSQL 序列
CREATE SEQUENCE xxl_job_user_id_seq START 1;
CREATE SEQUENCE xxl_job_info_id_seq START 1;
CREATE SEQUENCE xxl_job_log_id_seq START 1;
CREATE SEQUENCE xxl_job_log_report_id_seq START 1;
CREATE SEQUENCE xxl_job_logglue_id_seq START 1;
CREATE SEQUENCE xxl_job_registry_id_seq START 1;
CREATE SEQUENCE xxl_job_group_id_seq START 1; 修改 PostgreSQL 数据库表自增主键
ALTER TABLE public.xxl_job_user alter column ID set default nextval(xxl_job_user_id_seq::regclass);
ALTER TABLE public.xxl_job_info alter column ID set default nextval(xxl_job_info_id_seq::regclass);
ALTER TABLE public.xxl_job_log alter column ID set default nextval(xxl_job_log_id_seq::regclass);
ALTER TABLE public.xxl_job_log_report alter column ID set default nextval(xxl_job_log_report_id_seq::regclass);
ALTER TABLE public.xxl_job_logglue alter column ID set default nextval(xxl_job_logglue_id_seq::regclass);
ALTER TABLE public.xxl_job_registry alter column ID set default nextval(xxl_job_registry_id_seq::regclass);
ALTER TABLE public.xxl_job_group alter column ID set default nextval(xxl_job_group_id_seq::regclass);
修改源代码
修改 POM.xml 依赖添加postgresql
dependencygroupIdorg.postgresql/groupIdartifactIdpostgresql/artifactIdversion42.3.1/version
/dependency
在resource下面新建两个文件夹mysql和postgresql将mybatis-mapper文件夹下的xml文件拷贝到这两个文件夹下 修改配置文件指定xml文件的路径和数据库配置这样以后就可以兼容两种数据库根据配置信息使用相应的数据库。
mybatis.mapper-locationsclasspath:/postgresql/*Mapper.xml### xxl-job, datasource
#spring.datasource.urljdbc:mysql://127.0.0.1:3306/xxl_job?useUnicodetruecharacterEncodingUTF-8autoReconnecttrueserverTimezoneAsia/Shanghai
#spring.datasource.usernameroot
#spring.datasource.password123456
#spring.datasource.driver-class-namecom.mysql.cj.jdbc.Driverspring.datasource.urljdbc:postgresql://127.0.0.1:5432/xxl_job?currentSchemapublic
spring.datasource.schemaNamepublic
spring.datasource.usernameroot
spring.datasource.password123456
spring.datasource.driver-class-nameorg.postgresql.Driver
修改postgresql目录下的 Mapper 文件
去掉所有字段名的转义符 直接用空格替换。修改 LIMIT #{offset}, #{pagesize} 为 LIMIT #{pagesize} OFFSET #{offset} 。修改LIMIT 0, #{limit}为LIMIT #{limit} OFFSET 0。修改LIMIT 0, #{clearBeforeNum}为LIMIT #{clearBeforeNum} OFFSET 0。LIMIT #{pagesize}保持不变。修改DATE_ADD(#{nowTime},INTERVAL - #{timeout} SECOND) 为 (#{nowTime}::timestamp - ${timeout} SECONDS::interval)。修改 WHERE !( 为 WHERE not ( 。
编译运行成功 修改后的源代码及数据库建库脚本
https://download.csdn.net/download/xuruilll/88576748