gpt4 book ai didi

java - Quartz Scheduler创建没有quartz.properties的schedulerFactoryBean Bean

转载 作者:行者123 更新时间:2023-12-02 13:23:51 25 4
gpt4 key购买 nike

我在我的 Spring 应用程序中运行了quartz调度程序。

现在,我正在使用quartz.properties 来包含任何属性值,并使用它来创建schedulerFactoryBean Bean,它工作正常。

这是我的 QuartzConfiguration..

@Configuration
public class QuartzConfiguration {

public static final String CONTEXT_KEY = "applicationContext";

//@Autowired
//private DataSource dataSource;
@Bean
public SchedulerFactoryBean schedulerFactoryBean() {
SchedulerFactoryBean scheduler = new SchedulerFactoryBean();
scheduler.setApplicationContextSchedulerContextKey(CONTEXT_KEY);
scheduler.setConfigLocation(new ClassPathResource("config/quartz.properties"));
//scheduler.setDataSource(dataSource);
//scheduler.setAutoStartup(true);
scheduler.setWaitForJobsToCompleteOnShutdown(true);
return scheduler;
}

}

我的quartz.properties:

org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
org.quartz.jobStore.useProperties=false
org.quartz.jobStore.dataSource=myDS
org.quartz.dataSource.myDS.driver =oracle.jdbc.OracleDriver
org.quartz.dataSource.myDS.URL = jdbc:oracle:thin:@example:1521:db
org.quartz.dataSource.myDS.user = user
org.quartz.dataSource.myDS.password = password
org.quartz.dataSource.myDS.maxConnections = 5
org.quartz.dataSource.myDS.validationQuery = select 1 from dual
org.quartz.jobStore.isClustered=false
org.quartz.jobStore.tablePrefix = DPPA.QUARTZ_
org.quartz.threadPool.threadCount=1
org.quartz.scheduler.skipUpdateCheck=true
org.quartz.plugin.jobHistory.class=id.co.fifgroup.dpa.batch.BatchHistoryListener

我想创建没有任何quartz.properties的schedulerFactoryBean,因为我的客户不想更改war archive内的任何数据库连接。

是否可以在没有任何quartz.properties的情况下创建schedulerFactoryBean?

最佳答案

这样就可以在没有properties文件的情况下进行配置;

Properties p = new Properties();
p.put("org.quartz.scheduler.instanceName", "Scheduler_test");
p.put("org.quartz.threadPool.threadCount", 2);
...
StdSchedulerFactory factory = new StdSchedulerFactory(p);

关于java - Quartz Scheduler创建没有quartz.properties的schedulerFactoryBean Bean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43464977/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com