Skip to content

Commit 04307aa

Browse files
committed
Polish "Support @order on [CommandLine|Application]Runner @bean definitions"
See gh-37905
1 parent 8ac597c commit 04307aa

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ApplicationRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/CommandLineRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -670,11 +670,11 @@ void runCommandLineRunnersAndApplicationRunners() {
670670
}
671671

672672
@Test
673-
void runFunctionalCommandLineRunnersAndApplicationRunners() {
674-
SpringApplication application = new SpringApplication(FunctionalRunnerConfig.class);
673+
void runCommandLineRunnersAndApplicationRunnersUsingOrderOnBeanDefinitions() {
674+
SpringApplication application = new SpringApplication(BeanDefinitionOrderRunnerConfig.class);
675675
application.setWebApplicationType(WebApplicationType.NONE);
676676
this.context = application.run("arg");
677-
FunctionalRunnerConfig config = this.context.getBean(FunctionalRunnerConfig.class);
677+
BeanDefinitionOrderRunnerConfig config = this.context.getBean(BeanDefinitionOrderRunnerConfig.class);
678678
assertThat(config.runners).containsExactly("runnerA", "runnerB", "runnerC");
679679
}
680680

@@ -1585,12 +1585,12 @@ TestCommandLineRunner runnerA() {
15851585
}
15861586

15871587
@Configuration(proxyBeanMethods = false)
1588-
static class FunctionalRunnerConfig {
1588+
static class BeanDefinitionOrderRunnerConfig {
15891589

1590-
List<String> runners = new ArrayList<>();
1590+
private final List<String> runners = new ArrayList<>();
15911591

15921592
@Bean
1593-
@Order // default is LOWEST_PRECEDENCE
1593+
@Order
15941594
CommandLineRunner runnerC() {
15951595
return (args) -> this.runners.add("runnerC");
15961596
}

0 commit comments

Comments
 (0)