Skip to content

Commit

Permalink
Upgraded to Spring-Boot 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Julius Krah committed Apr 10, 2018
1 parent 45d0860 commit 41b518a
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 85 deletions.
11 changes: 2 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,21 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.juliuskrah</groupId>
<artifactId>quartz-manager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>2.2.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>quartz-manager</name>
<description>Demo project for Dynamic quartz jobs</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<version>2.0.1.RELEASE</version>
<relativePath />
<!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
<junit.jupiter.version>5.0.0</junit.jupiter.version>
<junit.vintage.version>${junit.version}.0</junit.vintage.version>
<junit.platform.version>1.0.0</junit.platform.version>
<spring-cloud-connectors.version>2.0.1.RELEASE</spring-cloud-connectors.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -73,7 +67,6 @@
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.0</version>
<exclusions>
<exclusion>
<groupId>com.zaxxer</groupId>
Expand Down
17 changes: 0 additions & 17 deletions src/main/java/com/juliuskrah/quartz/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,18 @@
import java.util.Properties;
import java.util.concurrent.Executor;

import javax.sql.DataSource;

import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.mail.MailProperties;
import org.springframework.boot.autoconfigure.quartz.AutowireCapableBeanJobFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

import com.juliuskrah.quartz.autoconfigure.QuartzProperties;
import com.juliuskrah.quartz.mail.javamail.AsyncMailSender;
Expand All @@ -50,7 +45,6 @@
public class Application implements AsyncConfigurer {
private final QuartzProperties quartzProperties;
private final MailProperties mailProperties;
private final ApplicationContext applicationContext;

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
Expand Down Expand Up @@ -78,17 +72,6 @@ private Properties asProperties(Map<String, String> source) {
return properties;
}

@Bean
public SchedulerFactoryBean schedulerFactory(Executor taskExecutor, DataSource dataSource) {
SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
schedulerFactoryBean.setDataSource(dataSource);
schedulerFactoryBean.setConfigLocation(quartzProperties.getConfigLocation());
schedulerFactoryBean.setTaskExecutor(taskExecutor);
schedulerFactoryBean.setJobFactory(new AutowireCapableBeanJobFactory(applicationContext.getAutowireCapableBeanFactory()));
schedulerFactoryBean.setApplicationContextSchedulerContextKey("applicationContext");
return schedulerFactoryBean;
}

@Override
@Bean(name = "taskExecutor")
public Executor getAsyncExecutor() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/juliuskrah/quartz/model/JobDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import java.util.Set;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;

import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
import static org.quartz.JobBuilder.*;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import java.time.LocalDateTime;
import java.util.TimeZone;

import org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.NotBlank;

import org.quartz.JobDataMap;
import org.quartz.Trigger;

Expand Down

This file was deleted.

7 changes: 3 additions & 4 deletions src/main/resources/application-postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ spring:
hikari:
username: postgres
password: root
com:
juliuskrah:
quartz:
config-location: classpath:quartz-postgres.properties
quartz:
properties:
org.quartz.jobStore.driverDelegateClass: org.quartz.impl.jdbcjobstore.PostgreSQLDelegate



Expand Down
12 changes: 9 additions & 3 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
liquibase:
enabled: true
spring:
jackson:
serialization:
write-dates-as-timestamps: false
liquibase:
enabled: true
mail:
host: ${MAIL_HOST}
port: ${MAIL_PORT}
Expand All @@ -13,12 +13,18 @@ spring:
properties:
mail.smtp.starttls.enable: true
jpa:
open-in-view: false
hibernate:
ddl-auto: none
quartz:
jdbc:
initialize-schema: never
job-store-type: jdbc
properties:
org.quartz.jobStore.driverDelegateClass: org.quartz.impl.jdbcjobstore.HSQLDBDelegate
com:
juliuskrah:
quartz:
config-location: classpath:quartz.properties
async:
core-pool-size: 5
max-pool-size: 6
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/quartz-postgres.properties

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/quartz.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
Expand Down

0 comments on commit 41b518a

Please sign in to comment.