我有一个带有application.properties文件的spring引导应用程序。该项目依赖于第三方库,在我的例子中,它:
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.0</version>
</dependency>库中有包含信任的quartz.properties文件。我想推翻一些价值观,例如:
org.quartz.threadPool.threadCount:10又有几个线程。
如何使用我自己的属性文件和/或环境变量来完成这个任务?
发布于 2018-08-23 17:46:21
对于Spring 2应用程序(假设您有spring starter石英),您可以直接指定以下属性:
弹簧:石英:性能: org.quartz.threadPool.threadCount:10
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-quartz.html
石英Scheduler配置可以通过使用Quartz配置属性() Quartz .Quartz.properties.*和SchedulerFactoryBeanCustomizer bean进行定制,这两种配置都允许编程SchedulerFactoryBean自定义。
发布于 2018-08-23 11:07:20
您可以重写此值,创建您自己的属性解析器:
@Bean
public Properties quartzProperties() throws IOException {
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
propertiesFactoryBean.afterPropertiesSet();
return propertiesFactoryBean.getObject();
}在你的quartz.properties中:
#============================================================================
# Configure Main Scheduler Properties
#============================================================================
org.quartz.scheduler.instanceId = AUTO
org.quartz.scheduler.threadsInheritContextClassLoaderOfInitializer = true
org.quartz.scheduler.skipUpdateCheck = true
#============================================================================
# Configure ThreadPool
#============================================================================
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 20
#Thread.MAX_PRIORITY 10
org.quartz.threadPool.threadPriority: 5
#============================================================================
# Configure JobStore
#============================================================================
org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore 在这里,您可以检查代码示例。
https://www.quickprogrammingtips.com/spring-boot/spring-boot-quartz-scheduler-integration.html
https://gist.github.com/cardosomarcos/149f915b966f7bb132f436dae5af1521
https://stackoverflow.com/questions/51984244
复制相似问题