Browse Source

Polish "Support @Order on [CommandLine|Application]Runner @Bean definitions"

See gh-37905
pull/38228/head
Andy Wilkinson 2 years ago
parent
commit
04307aa7e0
  1. 2
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ApplicationRunner.java
  2. 2
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/CommandLineRunner.java
  3. 12
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 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.

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2023 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.

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

@ -670,11 +670,11 @@ class SpringApplicationTests { @@ -670,11 +670,11 @@ class SpringApplicationTests {
}
@Test
void runFunctionalCommandLineRunnersAndApplicationRunners() {
SpringApplication application = new SpringApplication(FunctionalRunnerConfig.class);
void runCommandLineRunnersAndApplicationRunnersUsingOrderOnBeanDefinitions() {
SpringApplication application = new SpringApplication(BeanDefinitionOrderRunnerConfig.class);
application.setWebApplicationType(WebApplicationType.NONE);
this.context = application.run("arg");
FunctionalRunnerConfig config = this.context.getBean(FunctionalRunnerConfig.class);
BeanDefinitionOrderRunnerConfig config = this.context.getBean(BeanDefinitionOrderRunnerConfig.class);
assertThat(config.runners).containsExactly("runnerA", "runnerB", "runnerC");
}
@ -1585,12 +1585,12 @@ class SpringApplicationTests { @@ -1585,12 +1585,12 @@ class SpringApplicationTests {
}
@Configuration(proxyBeanMethods = false)
static class FunctionalRunnerConfig {
static class BeanDefinitionOrderRunnerConfig {
List<String> runners = new ArrayList<>();
private final List<String> runners = new ArrayList<>();
@Bean
@Order // default is LOWEST_PRECEDENCE
@Order
CommandLineRunner runnerC() {
return (args) -> this.runners.add("runnerC");
}

Loading…
Cancel
Save