修改数据库是pgsql时quartz启动失败问题

Signed-off-by: 王祁 <593401899@qq.com>
This commit is contained in:
王祁 2023-03-14 04:33:38 +00:00 committed by Gitee
parent 30530a6edc
commit 229e8c15b1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 14 additions and 0 deletions

View File

@ -3,6 +3,8 @@ package net.maku.quartz.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.beans.factory.annotation.Value;
import net.maku.framework.common.constant.Constant;
import javax.sql.DataSource;
import java.util.Properties;
@ -16,6 +18,9 @@ import java.util.Properties;
@Configuration
public class ScheduleConfig {
@Value("spring.datasource.driver-class-name")
private String driver;
@Bean
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) {
// quartz参数
@ -38,6 +43,10 @@ public class ScheduleConfig {
prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
//postgreSql数据库配置
if(Constant.PGSQL_DRIVER.equals(driver)){
prop.put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.PostgreSQLDelegate");
}
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setSchedulerName("MakuScheduler");
factory.setDataSource(dataSource);

View File

@ -44,4 +44,9 @@ public interface Constant {
*/
String OK = "OK";
/**
* pgsql的driver
*/
String PGSQL_DRIVER = "org.postgresql.Driver";
}