Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
442 views
in Technique[技术] by (71.8m points)

spring-boot-starter-quartz jdbc vs memory jobstore in different environement

I'm using spring-boot-starter-quartz in a several environements project.

In local env I'd like to use memory jobstore( spring.quartz.job-store-type=memory) In all other env (preprod, prod ...) I'd like to use jdbc jobstore (spring.quartz.job-store-type=jdbc)

I'd like to put in the default application.properties file all common properties and override only usefulls properties in Local env properties file (application-local.properties)

So typically i will put this in application.properties

spring.quartz.job-store-type=jdbc
spring.quartz.jdbc.initialize-schema=never
spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
spring.quartz.properties.org.quartz.jobStore.useProperties=false
spring.quartz.properties.org.quartz.jobStore.tablePrefix=qrtz_
spring.quartz.properties.org.quartz.jobStore.isClustered=false

And in application-local.properties

spring.quartz.jdbc.initialize-schema=always
spring.quartz.job-store-type=MEMORY

Quartz doesn't like this config. I'm facing exception like java.lang.NoSuchMethodException: No setter for property 'tablePrefix'

A trivial solution consists in repeating the required properties in each file(I definitely don't want this solution).

How can i do otherwise ?

question from:https://stackoverflow.com/questions/66052895/spring-boot-starter-quartz-jdbc-vs-memory-jobstore-in-different-environement

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

My approch was not the good one. We can use jdbc jobstore with h2 database. the only thing that change is the driverDelegateClass. For h2 we need to use the driverDelegateClass spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.HSQLDBDelegate.

So this config will work with h2 database :

spring.quartz.job-store-type=jdbc
spring.quartz.jdbc.initialize-schema=always
spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.HSQLDBDelegate
spring.quartz.properties.org.quartz.jobStore.useProperties=false
spring.quartz.properties.org.quartz.jobStore.tablePrefix=qrtz_
spring.quartz.properties.org.quartz.jobStore.isClustered=false

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...