Skip to content

Commit f378bdb

Browse files
authored
Spring Boot 3 upgrade (#128)
* Spring Boot 3 upgrade * upgrade to the latest Spring Boot 3.4.1 * use Java 17 (requirement for SB 3) * upgrade db-scheduler to the latest version & fix deprecated usage * upgrade & update plugins to their latest version * introduce spring-boot-configuration-processor to generate configuration metadata * update README for Java, SB and db-scheduler * test only against OSS Spring Boot versions not EOL fixes #127
1 parent 71ba464 commit f378bdb

File tree

25 files changed

+128
-111
lines changed

25 files changed

+128
-111
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ jobs:
3636
cd db-scheduler-ui-frontend
3737
npm install
3838
39-
- name: Set up JDK 11
39+
- name: Set up JDK 17
4040
uses: actions/setup-java@v3
4141
with:
42-
java-version: '11'
42+
java-version: '17'
4343
distribution: 'temurin'
4444

4545
- name: Build all packages with Maven

.github/workflows/pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ jobs:
1818
restore-keys: |
1919
${{ runner.os }}-maven-
2020
21-
- name: Set up JDK 11
21+
- name: Set up JDK 17
2222
uses: actions/setup-java@v3
2323
with:
24-
java-version: '11'
24+
java-version: '17'
2525
distribution: 'temurin'
2626

2727
- name: Run spotless check

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Set up JDK 17
3737
uses: actions/setup-java@v3
3838
with:
39-
java-version: '11'
39+
java-version: '17'
4040
distribution: 'temurin'
4141
gpg-private-key: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
4242
gpg-passphrase: JRELEASER_GPG_PASSPHRASE

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
spring-boot: [ '2.7.15', '3.0.6', '3.1.3' ]
11+
spring-boot: [ '3.3.7', '3.4.1' ]
1212

1313
steps:
1414
- name: Checkout repo

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ dashboard for monitoring and basic administration of tasks.
2828
### Prerequisites
2929

3030
* An existing Spring Boot application, with [db-scheduler](https://github.com/kagkarlsson/db-scheduler)
31-
* Minimum db-scheduler version 12.5
32-
* Minimum Java 11 and SpringBoot 2.7
31+
* Minimum db-scheduler version 15
32+
* Minimum Java 17 and SpringBoot 3.3
3333
* Optional (if you want task history): db-scheduler-log version 0.7.0
3434

3535
## Getting started
@@ -109,7 +109,7 @@ Please use the prettier config when making frontend changes
109109
Prerequisites:
110110

111111
* Maven
112-
* JDK11
112+
* JDK17
113113
* Node
114114
* npm
115115

db-scheduler-ui-starter/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
<url>https://github.com/bekk/db-scheduler-ui</url>
1515

1616
<dependencies>
17+
<dependency>
18+
<groupId>org.springframework.boot</groupId>
19+
<artifactId>spring-boot-configuration-processor</artifactId>
20+
<optional>true</optional>
21+
</dependency>
1722
<dependency>
1823
<groupId>com.github.kagkarlsson</groupId>
1924
<artifactId>db-scheduler-spring-boot-starter</artifactId>

example-app-webflux/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use the official OpenJDK base image
2-
FROM openjdk:11-jdk-slim
2+
FROM openjdk:17-jdk-slim
33

44
# Set the working directory inside the container
55
WORKDIR /app

example-app-webflux/src/main/java/com/github/bekk/exampleapp/service/TaskService.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,18 @@ public TaskService(Scheduler scheduler) {
3535

3636
public void runManuallyTriggeredTasks() {
3737
scheduler.schedule(
38-
ONE_TIME_TASK.instance("1", new TaskData(1, "test data", Instant.now())), Instant.now());
38+
ONE_TIME_TASK.instance("1").data(new TaskData(1, "test data", Instant.now())).build(),
39+
Instant.now());
3940

4041
scheduler.schedule(
41-
CHAINED_STEP_1_TASK.instance("3", new TestObject("Ole Nordman", 1, "[email protected]")),
42+
CHAINED_STEP_1_TASK
43+
.instance("3")
44+
.data(new TestObject("Ole Nordman", 1, "[email protected]"))
45+
.build(),
4246
Instant.now());
4347

44-
scheduler.schedule(LONG_RUNNING_ONETIME_TASK.instance("5"), Instant.now().plusSeconds(2));
45-
scheduler.schedule(FAILING_ONETIME_TASK.instance("6"), Instant.now().plusSeconds(2));
48+
scheduler.schedule(
49+
LONG_RUNNING_ONETIME_TASK.instance("5").build(), Instant.now().plusSeconds(2));
50+
scheduler.schedule(FAILING_ONETIME_TASK.instance("6").build(), Instant.now().plusSeconds(2));
4651
}
4752
}

example-app-webflux/src/main/java/com/github/bekk/exampleapp/tasks/ChainTask.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import com.github.bekk.exampleapp.model.TestObject;
1919
import com.github.kagkarlsson.scheduler.SchedulerClient;
2020
import com.github.kagkarlsson.scheduler.task.Task;
21-
import com.github.kagkarlsson.scheduler.task.TaskWithDataDescriptor;
21+
import com.github.kagkarlsson.scheduler.task.TaskDescriptor;
2222
import com.github.kagkarlsson.scheduler.task.helper.Tasks;
2323
import java.time.Instant;
2424
import org.springframework.context.annotation.Bean;
@@ -27,11 +27,11 @@
2727
@Configuration
2828
public class ChainTask {
2929

30-
public static final TaskWithDataDescriptor<TestObject> CHAINED_STEP_1_TASK =
31-
new TaskWithDataDescriptor<>("chained-step-1", TestObject.class);
30+
public static final TaskDescriptor<TestObject> CHAINED_STEP_1_TASK =
31+
TaskDescriptor.of("chained-step-1", TestObject.class);
3232

33-
public static final TaskWithDataDescriptor<TestObject> CHAINED_STEP_2_TASK =
34-
new TaskWithDataDescriptor<>("chained-step-2", TestObject.class);
33+
public static final TaskDescriptor<TestObject> CHAINED_STEP_2_TASK =
34+
TaskDescriptor.of("chained-step-2", TestObject.class);
3535

3636
@Bean
3737
public Task<TestObject> chainTaskStepOne() {
@@ -47,8 +47,9 @@ public Task<TestObject> chainTaskStepOne() {
4747
+ inst.getId());
4848
TestObject data = inst.getData();
4949
data.setId(data.getId() + 1);
50-
client.schedule(
51-
CHAINED_STEP_2_TASK.instance(inst.getId(), data), Instant.now().plusSeconds(10));
50+
client.scheduleIfNotExists(
51+
CHAINED_STEP_2_TASK.instance(inst.getId()).data(data).build(),
52+
Instant.now().plusSeconds(10));
5253
});
5354
}
5455

@@ -66,8 +67,9 @@ public Task<TestObject> chainTaskStepTwo() {
6667
+ inst.getId());
6768
TestObject data = inst.getData();
6869
data.setId(data.getId() + 1);
69-
client.schedule(
70-
CHAINED_STEP_1_TASK.instance(inst.getId(), data), Instant.now().plusSeconds(20));
70+
client.scheduleIfNotExists(
71+
CHAINED_STEP_1_TASK.instance(inst.getId()).data(data).build(),
72+
Instant.now().plusSeconds(20));
7173
});
7274
}
7375
}

example-app-webflux/src/main/java/com/github/bekk/exampleapp/tasks/FailingTask.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import com.github.kagkarlsson.scheduler.task.FailureHandler;
1919
import com.github.kagkarlsson.scheduler.task.Task;
20-
import com.github.kagkarlsson.scheduler.task.TaskWithoutDataDescriptor;
20+
import com.github.kagkarlsson.scheduler.task.TaskDescriptor;
2121
import com.github.kagkarlsson.scheduler.task.helper.Tasks;
2222
import com.github.kagkarlsson.scheduler.task.schedule.FixedDelay;
2323
import org.springframework.context.annotation.Bean;
@@ -26,14 +26,14 @@
2626
@Configuration
2727
public class FailingTask {
2828

29-
public static final TaskWithoutDataDescriptor FAILING_ONETIME_TASK =
30-
new TaskWithoutDataDescriptor("failing-one-time-task");
29+
public static final TaskDescriptor<Void> FAILING_ONETIME_TASK =
30+
TaskDescriptor.of("failing-one-time-task");
3131

32-
public static final TaskWithoutDataDescriptor FAILING_RECURRING_TASK =
33-
new TaskWithoutDataDescriptor("failing-recurring-task");
32+
public static final TaskDescriptor<Void> FAILING_RECURRING_TASK =
33+
TaskDescriptor.of("failing-recurring-task");
3434

35-
public static final TaskWithoutDataDescriptor FAILING_ONETIME_TASK_BACKOFF =
36-
new TaskWithoutDataDescriptor("failing-one-time-with-backoff-task");
35+
public static final TaskDescriptor<Void> FAILING_ONETIME_TASK_BACKOFF =
36+
TaskDescriptor.of("failing-one-time-with-backoff-task");
3737

3838
@Bean
3939
public Task<?> runOneTimeFailing() {

example-app-webflux/src/main/java/com/github/bekk/exampleapp/tasks/LongRunningTask.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import static utils.Utils.sleep;
1717

1818
import com.github.kagkarlsson.scheduler.task.Task;
19-
import com.github.kagkarlsson.scheduler.task.TaskWithoutDataDescriptor;
19+
import com.github.kagkarlsson.scheduler.task.TaskDescriptor;
2020
import com.github.kagkarlsson.scheduler.task.helper.Tasks;
2121
import com.github.kagkarlsson.scheduler.task.schedule.FixedDelay;
2222
import org.springframework.context.annotation.Bean;
@@ -25,11 +25,11 @@
2525
@Configuration
2626
public class LongRunningTask {
2727

28-
public static final TaskWithoutDataDescriptor LONG_RUNNING_ONETIME_TASK =
29-
new TaskWithoutDataDescriptor("long-running-task");
28+
public static final TaskDescriptor<Void> LONG_RUNNING_ONETIME_TASK =
29+
TaskDescriptor.of("long-running-task");
3030

31-
public static final TaskWithoutDataDescriptor LONG_RUNNING_RECURRING_TASK =
32-
new TaskWithoutDataDescriptor("long-running-recurring-task");
31+
public static final TaskDescriptor<Void> LONG_RUNNING_RECURRING_TASK =
32+
TaskDescriptor.of("long-running-recurring-task");
3333

3434
@Bean
3535
public Task<?> runLongRunningTask() {

example-app-webflux/src/main/java/com/github/bekk/exampleapp/tasks/OneTimeTaskExample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515

1616
import com.github.bekk.exampleapp.model.TaskData;
1717
import com.github.kagkarlsson.scheduler.task.Task;
18-
import com.github.kagkarlsson.scheduler.task.TaskWithDataDescriptor;
18+
import com.github.kagkarlsson.scheduler.task.TaskDescriptor;
1919
import com.github.kagkarlsson.scheduler.task.helper.Tasks;
2020
import org.springframework.context.annotation.Bean;
2121
import org.springframework.context.annotation.Configuration;
2222

2323
@Configuration
2424
public class OneTimeTaskExample {
2525

26-
public static final TaskWithDataDescriptor<TaskData> ONE_TIME_TASK =
27-
new TaskWithDataDescriptor<>("onetime-task", TaskData.class);
26+
public static final TaskDescriptor<TaskData> ONE_TIME_TASK =
27+
TaskDescriptor.of("onetime-task", TaskData.class);
2828

2929
@Bean
3030
public Task<TaskData> exampleOneTimeTask() {

example-app-webflux/src/main/java/com/github/bekk/exampleapp/tasks/RecurringTaskExample.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import static utils.Utils.sleep;
1717

18-
import com.github.kagkarlsson.scheduler.task.TaskWithoutDataDescriptor;
18+
import com.github.kagkarlsson.scheduler.task.TaskDescriptor;
1919
import com.github.kagkarlsson.scheduler.task.helper.RecurringTask;
2020
import com.github.kagkarlsson.scheduler.task.helper.Tasks;
2121
import com.github.kagkarlsson.scheduler.task.schedule.FixedDelay;
@@ -26,8 +26,7 @@
2626
@Configuration
2727
public class RecurringTaskExample {
2828

29-
public static final TaskWithoutDataDescriptor RECURRING_TASK =
30-
new TaskWithoutDataDescriptor("recurring-task");
29+
public static final TaskDescriptor<Void> RECURRING_TASK = TaskDescriptor.of("recurring-task");
3130

3231
@Bean
3332
public RecurringTask<Void> getExample() {

example-app-webflux/src/main/java/com/github/bekk/exampleapp/tasks/SpawnerTask.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
import com.github.bekk.exampleapp.model.TaskData;
1919
import com.github.kagkarlsson.scheduler.SchedulerClient;
2020
import com.github.kagkarlsson.scheduler.task.Task;
21-
import com.github.kagkarlsson.scheduler.task.TaskWithDataDescriptor;
22-
import com.github.kagkarlsson.scheduler.task.TaskWithoutDataDescriptor;
21+
import com.github.kagkarlsson.scheduler.task.TaskDescriptor;
2322
import com.github.kagkarlsson.scheduler.task.helper.Tasks;
2423
import com.github.kagkarlsson.scheduler.task.schedule.FixedDelay;
2524
import java.time.Instant;
@@ -31,11 +30,11 @@
3130
@Configuration
3231
public class SpawnerTask {
3332

34-
public static final TaskWithoutDataDescriptor RECURRING_SPAWNER_TASK =
35-
new TaskWithoutDataDescriptor("recurring-spawner-task");
33+
public static final TaskDescriptor<Void> RECURRING_SPAWNER_TASK =
34+
TaskDescriptor.of("recurring-spawner-task");
3635

37-
public static final TaskWithDataDescriptor<TaskData> ONE_TIME_SPAWNER_TASK =
38-
new TaskWithDataDescriptor<>("onetime-spawned-task", TaskData.class);
36+
public static final TaskDescriptor<TaskData> ONE_TIME_SPAWNER_TASK =
37+
TaskDescriptor.of("onetime-spawned-task", TaskData.class);
3938

4039
@Bean
4140
public Task<?> runSpawner() {
@@ -46,10 +45,11 @@ public Task<?> runSpawner() {
4645
final long randomUUID = UUID.randomUUID().getMostSignificantBits() & Long.MAX_VALUE;
4746

4847
for (int i = 0; i < 100; i++) {
49-
client.schedule(
50-
ONE_TIME_SPAWNER_TASK.instance(
51-
"spawned " + randomUUID + " loopnr: " + i,
52-
new TaskData(123, "{data: MASSIVEDATA}", Instant.now())),
48+
client.scheduleIfNotExists(
49+
ONE_TIME_SPAWNER_TASK
50+
.instance("spawned " + randomUUID + " loopnr: " + i)
51+
.data(new TaskData(123, "{data: MASSIVEDATA}", Instant.now()))
52+
.build(),
5353
Instant.now().plusSeconds(60));
5454
}
5555
});

example-app/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use the official OpenJDK base image
2-
FROM openjdk:11-jdk-slim
2+
FROM openjdk:17-jdk-slim
33

44
# Set the working directory inside the container
55
WORKDIR /app

example-app/src/main/java/com/github/bekk/exampleapp/service/TaskService.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,18 @@ public TaskService(Scheduler scheduler) {
3535

3636
public void runManuallyTriggeredTasks() {
3737
scheduler.schedule(
38-
ONE_TIME_TASK.instance("1", new TaskData(1, "test data", Instant.now())), Instant.now());
38+
ONE_TIME_TASK.instance("1").data(new TaskData(1, "test data", Instant.now())).build(),
39+
Instant.now());
3940

4041
scheduler.schedule(
41-
CHAINED_STEP_1_TASK.instance("3", new TestObject("Ole Nordman", 1, "[email protected]")),
42+
CHAINED_STEP_1_TASK
43+
.instance("3")
44+
.data(new TestObject("Ole Nordman", 1, "[email protected]"))
45+
.build(),
4246
Instant.now());
4347

44-
scheduler.schedule(LONG_RUNNING_ONETIME_TASK.instance("5"), Instant.now().plusSeconds(2));
45-
scheduler.schedule(FAILING_ONETIME_TASK.instance("6"), Instant.now().plusSeconds(2));
48+
scheduler.schedule(
49+
LONG_RUNNING_ONETIME_TASK.instance("5").build(), Instant.now().plusSeconds(2));
50+
scheduler.schedule(FAILING_ONETIME_TASK.instance("6").build(), Instant.now().plusSeconds(2));
4651
}
4752
}

example-app/src/main/java/com/github/bekk/exampleapp/tasks/ChainTask.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import com.github.bekk.exampleapp.model.TestObject;
1919
import com.github.kagkarlsson.scheduler.SchedulerClient;
2020
import com.github.kagkarlsson.scheduler.task.Task;
21-
import com.github.kagkarlsson.scheduler.task.TaskWithDataDescriptor;
21+
import com.github.kagkarlsson.scheduler.task.TaskDescriptor;
2222
import com.github.kagkarlsson.scheduler.task.helper.Tasks;
2323
import java.time.Instant;
2424
import org.springframework.context.annotation.Bean;
@@ -27,11 +27,11 @@
2727
@Configuration
2828
public class ChainTask {
2929

30-
public static final TaskWithDataDescriptor<TestObject> CHAINED_STEP_1_TASK =
31-
new TaskWithDataDescriptor<>("chained-step-1", TestObject.class);
30+
public static final TaskDescriptor<TestObject> CHAINED_STEP_1_TASK =
31+
TaskDescriptor.of("chained-step-1", TestObject.class);
3232

33-
public static final TaskWithDataDescriptor<TestObject> CHAINED_STEP_2_TASK =
34-
new TaskWithDataDescriptor<>("chained-step-2", TestObject.class);
33+
public static final TaskDescriptor<TestObject> CHAINED_STEP_2_TASK =
34+
TaskDescriptor.of("chained-step-2", TestObject.class);
3535

3636
@Bean
3737
public Task<TestObject> chainTaskStepOne() {
@@ -47,8 +47,9 @@ public Task<TestObject> chainTaskStepOne() {
4747
+ inst.getId());
4848
TestObject data = inst.getData();
4949
data.setId(data.getId() + 1);
50-
client.schedule(
51-
CHAINED_STEP_2_TASK.instance(inst.getId(), data), Instant.now().plusSeconds(10));
50+
client.scheduleIfNotExists(
51+
CHAINED_STEP_2_TASK.instance(inst.getId()).data(data).build(),
52+
Instant.now().plusSeconds(10));
5253
});
5354
}
5455

@@ -66,8 +67,9 @@ public Task<TestObject> chainTaskStepTwo() {
6667
+ inst.getId());
6768
TestObject data = inst.getData();
6869
data.setId(data.getId() + 1);
69-
client.schedule(
70-
CHAINED_STEP_1_TASK.instance(inst.getId(), data), Instant.now().plusSeconds(20));
70+
client.scheduleIfNotExists(
71+
CHAINED_STEP_1_TASK.instance(inst.getId()).data(data).build(),
72+
Instant.now().plusSeconds(20));
7173
});
7274
}
7375
}

example-app/src/main/java/com/github/bekk/exampleapp/tasks/DynamicRecurringTaskExample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
package com.github.bekk.exampleapp.tasks;
1515

1616
import com.github.bekk.exampleapp.model.TaskScheduleAndNoData;
17-
import com.github.kagkarlsson.scheduler.task.TaskWithDataDescriptor;
17+
import com.github.kagkarlsson.scheduler.task.TaskDescriptor;
1818
import com.github.kagkarlsson.scheduler.task.helper.RecurringTaskWithPersistentSchedule;
1919
import com.github.kagkarlsson.scheduler.task.helper.Tasks;
2020
import org.springframework.context.annotation.Bean;
@@ -24,8 +24,8 @@
2424
@Configuration
2525
public class DynamicRecurringTaskExample {
2626

27-
public static final TaskWithDataDescriptor<TaskScheduleAndNoData> DYNAMIC_RECURRING_TASK =
28-
new TaskWithDataDescriptor<>("dynamic-recurring-task", TaskScheduleAndNoData.class);
27+
public static final TaskDescriptor<TaskScheduleAndNoData> DYNAMIC_RECURRING_TASK =
28+
TaskDescriptor.of("dynamic-recurring-task", TaskScheduleAndNoData.class);
2929

3030
@Bean
3131
public RecurringTaskWithPersistentSchedule<TaskScheduleAndNoData> runDynamicRecurringTask() {

0 commit comments

Comments
 (0)