diff --git a/spring-boot-autoconfigure/pom.xml b/spring-boot-autoconfigure/pom.xml
index 2126c5c248..1b7893a057 100755
--- a/spring-boot-autoconfigure/pom.xml
+++ b/spring-boot-autoconfigure/pom.xml
@@ -656,6 +656,11 @@
narayana-jts-integration
true
+
+ org.quartz-scheduler
+ quartz
+ true
+
org.springframework.boot
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/AutowireCapableBeanJobFactory.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/AutowireCapableBeanJobFactory.java
new file mode 100644
index 0000000000..36828976da
--- /dev/null
+++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/AutowireCapableBeanJobFactory.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2012-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.boot.autoconfigure.quartz;
+
+import org.quartz.spi.TriggerFiredBundle;
+
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.scheduling.quartz.SpringBeanJobFactory;
+import org.springframework.util.Assert;
+
+/**
+ * Subclass of {@link SpringBeanJobFactory} that supports auto-wiring job beans.
+ *
+ * @author Vedran Pavic
+ * @since 2.0.0
+ * @see Inject application
+ * context dependencies in Quartz job beans
+ */
+class AutowireCapableBeanJobFactory extends SpringBeanJobFactory {
+
+ private final AutowireCapableBeanFactory beanFactory;
+
+ AutowireCapableBeanJobFactory(AutowireCapableBeanFactory beanFactory) {
+ Assert.notNull(beanFactory, "Bean factory must not be null");
+ this.beanFactory = beanFactory;
+ }
+
+ @Override
+ protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
+ Object jobInstance = super.createJobInstance(bundle);
+ this.beanFactory.autowireBean(jobInstance);
+ this.beanFactory.initializeBean(jobInstance, null);
+ return jobInstance;
+ }
+
+}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/JobStoreType.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/JobStoreType.java
new file mode 100644
index 0000000000..e7673d4288
--- /dev/null
+++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/JobStoreType.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2012-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.boot.autoconfigure.quartz;
+
+/**
+ * Define the supported Quartz {@code JobStore}.
+ *
+ * @author Stephane Nicoll
+ * @since 2.0.0
+ */
+public enum JobStoreType {
+
+ /**
+ * Store jobs in memory.
+ */
+ MEMORY,
+
+ /**
+ * Store jobs in the database.
+ */
+ JDBC
+
+}
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java
new file mode 100644
index 0000000000..284db53cf8
--- /dev/null
+++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2012-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.boot.autoconfigure.quartz;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.Executor;
+
+import javax.sql.DataSource;
+
+import org.quartz.Calendar;
+import org.quartz.JobDetail;
+import org.quartz.Scheduler;
+import org.quartz.Trigger;
+
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+import org.springframework.transaction.PlatformTransactionManager;
+
+/**
+ * {@link EnableAutoConfiguration Auto-configuration} for Quartz Scheduler.
+ *
+ * @author Vedran Pavic
+ * @author Stephane Nicoll
+ * @since 2.0.0
+ */
+@Configuration
+@ConditionalOnClass({ Scheduler.class, SchedulerFactoryBean.class,
+ PlatformTransactionManager.class })
+@EnableConfigurationProperties(QuartzProperties.class)
+@AutoConfigureAfter({ DataSourceAutoConfiguration.class,
+ HibernateJpaAutoConfiguration.class })
+public class QuartzAutoConfiguration {
+
+ private final QuartzProperties properties;
+
+ private final List customizers;
+
+ private final Executor taskExecutor;
+
+ private final JobDetail[] jobDetails;
+
+ private final Map calendars;
+
+ private final Trigger[] triggers;
+
+ private final ApplicationContext applicationContext;
+
+ public QuartzAutoConfiguration(QuartzProperties properties,
+ ObjectProvider> customizers,
+ ObjectProvider taskExecutor, ObjectProvider jobDetails,
+ ObjectProvider
+
+ org.springframework.boot
+ spring-boot-starter-quartz
+ 2.0.0.BUILD-SNAPSHOT
+
org.springframework.boot
spring-boot-starter-security
@@ -1970,6 +1976,11 @@
lombok
${lombok.version}
+
+ org.quartz-scheduler
+ quartz
+ ${quartz.version}
+
org.seleniumhq.selenium
htmlunit-driver
diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
index be9b741429..67367e74c6 100644
--- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
+++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
@@ -129,6 +129,12 @@ content into your application; rather pick only the properties that you need.
spring.profiles.active= # Comma-separated list (or list if using YAML) of <>.
spring.profiles.include= # Unconditionally activate the specified comma separated profiles (or list of profiles if using YAML).
+ # QUARTZ SCHEDULER ({sc-spring-boot-autoconfigure}/quartz/QuartzProperties.{sc-ext}[QuartzProperties])
+ spring.quartz.job-store-type=memory # Quartz job store type.
+ spring.quartz.properties.*= # Additional Quartz Scheduler properties.
+ spring.quartz.jdbc.initialize-schema=false # Create the required Quartz Scheduler tables on startup.
+ spring.quartz.jdbc.schema=classpath:org/quartz/impl/jdbcjobstore/tables_@@platform@@.sql # Path to the SQL file to use to initialize the database schema.
+
# Reactor
spring.reactor.stacktrace-mode.enabled=false # Set whether Reactor should collect stacktrace information at runtime.
diff --git a/spring-boot-docs/src/main/asciidoc/index.adoc b/spring-boot-docs/src/main/asciidoc/index.adoc
index 21a401598b..2672eda029 100644
--- a/spring-boot-docs/src/main/asciidoc/index.adoc
+++ b/spring-boot-docs/src/main/asciidoc/index.adoc
@@ -1,5 +1,5 @@
= Spring Boot Reference Guide
-Phillip Webb; Dave Syer; Josh Long; Stéphane Nicoll; Rob Winch; Andy Wilkinson; Marcel Overdijk; Christian Dupuis; Sébastien Deleuze; Michael Simons
+Phillip Webb; Dave Syer; Josh Long; Stéphane Nicoll; Rob Winch; Andy Wilkinson; Marcel Overdijk; Christian Dupuis; Sébastien Deleuze; Michael Simons; Vedran Pavić
:doctype: book
:toc:
:toclevels: 4
diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
index 76974087b4..6b3b9580cf 100644
--- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
@@ -5151,6 +5151,71 @@ caching is enabled.
+[[boot-features-quartz]]
+== Quartz Scheduler
+Spring Boot offers several conveniences for working with the Quartz scheduler, including
+the `spring-boot-starter-quartz` '`Starter`'. If Quartz is available, a `Scheduler` will
+be auto-configured (via the `SchedulerFactoryBean` abstraction).
+
+Beans of the following types will be automatically picked up and associated with the
+the `Scheduler`:
+
+* `JobDetail`: defines a particular Job. `JobDetail` instance can easily be built with
+the `JobBuilder` API
+* `Calendar`
+* `Trigger`: defines when a particular job is triggered
+
+By default, an in-memory `JobStore` will be used. However, it is possible to configure
+a JDBC-based store if a `DataSource` bean is available in your application and if the
+`spring.quartz.job-store-type` property is configured accordingly:
+
+[source,properties,indent=0]
+----
+ spring.quartz.job-store-type=jdbc
+----
+
+When the jdbc store is used, the schema can be initialized on startup:
+
+[source,properties,indent=0]
+----
+ spring.quartz.jdbc.initialize-schema=true
+----
+
+NOTE: The database is detected by default and initialized using the standard scripts
+provided with the Quartz library. It is also possible to provide a custom script using the
+`spring.quartz.jdbc.schema` property.
+
+Quartz Scheduler configuration can be customized using Quartz configuration properties (see
+`spring.quartz.properties.*`) and `SchedulerFactoryBeanCustomizer` beans which allows
+programmatic `SchedulerFactoryBean` customization.
+
+Job can define setters to inject data map properties. Regular beans can also be injected
+in a similar manner:
+
+[source,java,indent=0]
+----
+ public class SampleJob extends QuartzJobBean {
+
+ private MyService myService;
+ private String name;
+
+ // Inject "MyService" bean
+ public void setMyService(MyService myService) { ... }
+
+ // Inject the "name" job data property
+ public void setName(String name) { ... }
+
+ @Override
+ protected void executeInternal(JobExecutionContext context)
+ throws JobExecutionException {
+ ...
+ }
+
+ }
+----
+
+
+
[[boot-features-integration]]
== Spring Integration
Spring Boot offers several conveniences for working with Spring Integration, including
diff --git a/spring-boot-samples/pom.xml b/spring-boot-samples/pom.xml
index 7a263b0994..8fa1bc4280 100644
--- a/spring-boot-samples/pom.xml
+++ b/spring-boot-samples/pom.xml
@@ -71,6 +71,7 @@
spring-boot-sample-parent-context
spring-boot-sample-profile
spring-boot-sample-property-validation
+ spring-boot-sample-quartz
spring-boot-sample-secure
spring-boot-sample-secure-oauth2
spring-boot-sample-secure-oauth2-actuator
diff --git a/spring-boot-samples/spring-boot-sample-quartz/README.adoc b/spring-boot-samples/spring-boot-sample-quartz/README.adoc
new file mode 100644
index 0000000000..e90a709db9
--- /dev/null
+++ b/spring-boot-samples/spring-boot-sample-quartz/README.adoc
@@ -0,0 +1,11 @@
+== Spring Boot Quartz Sample
+
+This sample demonstrates the Quartz auto-configuration support.
+
+The sample uses Maven. It can be built and run from the command line:
+
+----
+$ mvn spring-boot:run
+----
+
+Console log will now show "Hello World!" from `SampleJob` every 2 seconds.
diff --git a/spring-boot-samples/spring-boot-sample-quartz/pom.xml b/spring-boot-samples/spring-boot-sample-quartz/pom.xml
new file mode 100644
index 0000000000..a161afa0be
--- /dev/null
+++ b/spring-boot-samples/spring-boot-sample-quartz/pom.xml
@@ -0,0 +1,35 @@
+
+
+ 4.0.0
+
+
+ org.springframework.boot
+ spring-boot-samples
+ 2.0.0.BUILD-SNAPSHOT
+
+ spring-boot-sample-quartz
+ Spring Boot Quartz Sample
+ Spring Boot Quartz Sample
+ http://projects.spring.io/spring-boot/
+
+ Pivotal Software, Inc.
+ http://www.spring.io
+
+
+ ${basedir}/../..
+
+
+
+ org.springframework.boot
+ spring-boot-starter-quartz
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
diff --git a/spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleJob.java b/spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleJob.java
new file mode 100644
index 0000000000..b1d3db23ca
--- /dev/null
+++ b/spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleJob.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2012-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package sample.quartz;
+
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import org.springframework.scheduling.quartz.QuartzJobBean;
+
+public class SampleJob extends QuartzJobBean {
+
+ private String name;
+
+ // Invoked if a Job data map entry with that name
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ protected void executeInternal(JobExecutionContext context)
+ throws JobExecutionException {
+ System.out.println(String.format("Hello %s!", this.name));
+ }
+
+}
diff --git a/spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleQuartzApplication.java b/spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleQuartzApplication.java
new file mode 100644
index 0000000000..0836fa78a4
--- /dev/null
+++ b/spring-boot-samples/spring-boot-sample-quartz/src/main/java/sample/quartz/SampleQuartzApplication.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2012-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package sample.quartz;
+
+import org.quartz.JobBuilder;
+import org.quartz.JobDetail;
+import org.quartz.SimpleScheduleBuilder;
+import org.quartz.Trigger;
+import org.quartz.TriggerBuilder;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+
+@SpringBootApplication
+public class SampleQuartzApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SampleQuartzApplication.class, args);
+ }
+
+ @Bean
+ public JobDetail sampleJobDetail() {
+ return JobBuilder.newJob().ofType(SampleJob.class).withIdentity("sampleJob")
+ .usingJobData("name", "World")
+ .storeDurably().build();
+ }
+
+ @Bean
+ public Trigger sampleJobTrigger() {
+ SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
+ .withIntervalInSeconds(2).repeatForever();
+
+ return TriggerBuilder.newTrigger().forJob(sampleJobDetail())
+ .withIdentity("sampleTrigger").withSchedule(scheduleBuilder).build();
+ }
+
+}
diff --git a/spring-boot-starters/pom.xml b/spring-boot-starters/pom.xml
index eaff2e49ab..ddf430ce25 100644
--- a/spring-boot-starters/pom.xml
+++ b/spring-boot-starters/pom.xml
@@ -59,6 +59,7 @@
spring-boot-starter-mustache
spring-boot-starter-actuator
spring-boot-starter-parent
+ spring-boot-starter-quartz
spring-boot-starter-reactor-netty
spring-boot-starter-security
spring-boot-starter-social-facebook
diff --git a/spring-boot-starters/spring-boot-starter-quartz/pom.xml b/spring-boot-starters/spring-boot-starter-quartz/pom.xml
new file mode 100644
index 0000000000..a2f0c7489f
--- /dev/null
+++ b/spring-boot-starters/spring-boot-starter-quartz/pom.xml
@@ -0,0 +1,38 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starters
+ 2.0.0.BUILD-SNAPSHOT
+
+ spring-boot-starter-quartz
+ Spring Boot Quartz Starter
+ Spring Boot Quartz Starter
+ http://projects.spring.io/spring-boot/
+
+ Pivotal Software, Inc.
+ http://www.spring.io
+
+
+ ${basedir}/../..
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.springframework
+ spring-context-support
+
+
+ org.springframework
+ spring-tx
+
+
+ org.quartz-scheduler
+ quartz
+
+
+
diff --git a/spring-boot-starters/spring-boot-starter-quartz/src/main/resources/META-INF/spring.provides b/spring-boot-starters/spring-boot-starter-quartz/src/main/resources/META-INF/spring.provides
new file mode 100644
index 0000000000..55020b99f9
--- /dev/null
+++ b/spring-boot-starters/spring-boot-starter-quartz/src/main/resources/META-INF/spring.provides
@@ -0,0 +1 @@
+provides: spring-context-support,spring-tx,quartz