Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在quartz schedular中设置数据源。[错误]org.quartz.SchedulerException:无法初始化数据源:myDS_Java_Spring Boot_Spring Mvc_Spring Data Jpa_Quartz Scheduler - Fatal编程技术网

Java 如何在quartz schedular中设置数据源。[错误]org.quartz.SchedulerException:无法初始化数据源:myDS

Java 如何在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

这是我的配置文件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.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