forked from eugenp/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changes after code review - removed module within module, java versio…
…n to 1.8, boot version to 1.2.6, removed empty tests, removed named beans
- Loading branch information
1 parent
6ba4952
commit 854ddca
Showing
15 changed files
with
126 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
========= | ||
========================================================================= | ||
|
||
## Scheduling in Spring with Quartz Example Project | ||
This is the first example where we configure a basic scheduler. | ||
##### Spring boot application, Main class | ||
### | ||
``` | ||
org.baeldung.springquartz.SpringQuartzApp | ||
``` | ||
###### | ||
|
||
##### Configuration in *application.properties* | ||
#### | ||
|
||
- Default: configures scheduler using Spring convenience classes: | ||
``` | ||
using.spring.schedulerFactory=true | ||
``` | ||
- To configure scheduler using Quartz API: | ||
``` | ||
using.spring.schedulerFactory=false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,82 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.baeldung</groupId> | ||
<artifactId>spring-quartz</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<modules> | ||
<module>spring-quartz-basics</module> | ||
</modules> | ||
<packaging>pom</packaging> | ||
|
||
<name>spring-quartz</name> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
<description>Demo project for Scheduling in Spring with Quartz</description> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>1.1.12.RELEASE</version> | ||
<version>1.2.6.RELEASE</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<java.version>1.7</java.version> | ||
<java.version>1.8</java.version> | ||
</properties> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-jdbc</artifactId> | ||
</dependency> | ||
|
||
<!-- spring's support for quartz --> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context-support</artifactId> | ||
</dependency> | ||
|
||
<!-- quartz --> | ||
<dependency> | ||
<groupId>org.quartz-scheduler</groupId> | ||
<artifactId>quartz</artifactId> | ||
<version>2.2.1</version> | ||
</dependency> | ||
|
||
<!-- tests --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
|
||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
|
||
<!-- Spring boot maven plugin --> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> | ||
</project> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...g-quartz-basics/src/test/java/org/baeldung/springquartz/SpringQuartzApplicationTests.java
This file was deleted.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
...g/springquartz/SpringQuartzBasicsApp.java → ...aeldung/springquartz/SpringQuartzApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
package org.baeldung.springquartz; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.builder.SpringApplicationBuilder; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
|
||
@Configuration | ||
@ComponentScan | ||
@EnableScheduling | ||
public class SpringQuartzBasicsApp { | ||
public class SpringQuartzApp { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SpringQuartzBasicsApp.class, args); | ||
new SpringApplicationBuilder(SpringQuartzApp.class) | ||
.showBanner(false).run(args); | ||
} | ||
} |
46 changes: 22 additions & 24 deletions
46
...springquartz/scheduler/QrtzScheduler.java → ...uartz/basics/scheduler/QrtzScheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 5 additions & 6 deletions
11
...ung/springquartz/scheduler/SampleJob.java → ...ingquartz/basics/scheduler/SampleJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
package org.baeldung.springquartz.scheduler; | ||
package org.baeldung.springquartz.basics.scheduler; | ||
|
||
import org.baeldung.springquartz.service.SampleJobService; | ||
import org.baeldung.springquartz.basics.service.SampleJobService; | ||
import org.quartz.Job; | ||
import org.quartz.JobExecutionContext; | ||
import org.quartz.JobExecutionException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Scope; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class SampleJob implements Job { | ||
|
||
Logger _logger = LoggerFactory.getLogger(getClass()); | ||
Logger logger = LoggerFactory.getLogger(getClass()); | ||
|
||
@Autowired | ||
private SampleJobService jobService; | ||
|
||
public void execute(JobExecutionContext context) throws JobExecutionException { | ||
|
||
_logger.info("Job **{}** fired @ {}", context.getJobDetail().getKey().getName(), | ||
logger.info("Job ** {} ** fired @ {}", context.getJobDetail().getKey().getName(), | ||
context.getFireTime()); | ||
|
||
jobService.executeSampleJob(); | ||
|
||
_logger.info("Next job scheduled @ {}", context.getNextFireTime()); | ||
logger.info("Next job scheduled @ {}", context.getNextFireTime()); | ||
} | ||
} |
Oops, something went wrong.