Java 如何在quartz schedular中设置数据源。[错误]org.quartz.SchedulerException:无法初始化数据源:myDS
这是我的配置文件quartz.propertiesJava 如何在quartz schedular中设置数据源。[错误]org.quartz.SchedulerException:无法初始化数据源:myDS,java,spring-boot,spring-mvc,spring-data-jpa,quartz-scheduler,Java,Spring Boot,Spring Mvc,Spring Data Jpa,Quartz Scheduler,这是我的配置文件quartz.properties org.quartz.scheduler.instanceName= LivingOrdering org.quartz.scheduler.instanceId=99199 org.quartz.scheduler.rmi.export=false org.quartz.scheduler.rmi.proxy=false org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
org.quartz.scheduler.instanceName= LivingOrdering
org.quartz.scheduler.instanceId=99199
org.quartz.scheduler.rmi.export=false
org.quartz.scheduler.rmi.proxy=false
org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount=3
org.quartz.context.key.QuartzTopic=QuartzPorperties
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.tablePrefix=qrtz_
org.quartz.jobStore.dataSource=quartzDataSource
org.quartz.dataSource.quartzDataSource.driver=org.postgresql.Driver
org.quartz.dataSource.quartzDataSource.URL=jdbc:postgresql://localhost:5432/quartz
org.quartz.dataSource.quartzDataSource.user=admin
org.quartz.dataSource.quartzDataSource.password=admin
org.quartz.dataSource.quartzDataSource.maxConnections=300
我在线路上出错-:
Scheduler Scheduler=new StdSchedulerFactory().getScheduler();
SpringBoot具有Quartz自动配置,您不需要使用Quartz.properties配置Quartz,因为它对Spring一无所知,所以您不能只在其中输入数据源名称。阅读 开始使用Quartz只需在pom.xml中包含初学者:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
然后添加(在application.properties中):
如果要将其他属性传递给Quartz,可以在属性名称前面加上spring.Quartz.properties
,如下所示:
spring.quartz.properties.org.quartz.scheduler.instanceName=LivingOrdering
spring.datasource.url = jdbc:postgresql://localhost:5432/quartz
spring.datasource.username = admin
spring.datasource.password = admin
spring.quartz.job-store-type=jdbc
# Add the below line to have Spring Boot auto create the Quartz tables
spring.quartz.jdbc.initialize-schema=always
spring.quartz.properties.org.quartz.scheduler.instanceName=LivingOrdering