Rename SpringApplication.defaultCommandLineArgs
Rename SpringApplication.defaultCommandLineArgs to defaultArgs for consistency with the run() method arguments. Issue: #55202844
This commit is contained in:
committed by
Phillip Webb
parent
5b77028f04
commit
76bda7e3b4
@@ -162,7 +162,7 @@ public class SpringApplication {
|
||||
|
||||
private List<ApplicationContextInitializer<?>> initializers;
|
||||
|
||||
private String[] defaultCommandLineArgs;
|
||||
private String[] defaultArgs;
|
||||
|
||||
/**
|
||||
* Crate a new {@link SpringApplication} instance. The application context will load
|
||||
@@ -312,10 +312,10 @@ public class SpringApplication {
|
||||
*/
|
||||
protected void addPropertySources(ConfigurableEnvironment environment, String[] args) {
|
||||
if (this.addCommandLineProperties) {
|
||||
if (this.defaultCommandLineArgs != null) {
|
||||
if (this.defaultArgs != null) {
|
||||
environment.getPropertySources().addFirst(
|
||||
new SimpleCommandLinePropertySource("defaultCommandLineArgs",
|
||||
this.defaultCommandLineArgs));
|
||||
this.defaultArgs));
|
||||
}
|
||||
environment.getPropertySources().addFirst(
|
||||
new SimpleCommandLinePropertySource(args));
|
||||
@@ -543,13 +543,13 @@ public class SpringApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default command line arguments which will be used in addition to those
|
||||
* specified to the {@code run} methods. Default arguments can always be overridden by
|
||||
* user defined arguments..
|
||||
* @param defaultCommandLineArgs the default command line args to set
|
||||
* Set default arguments which will be used in addition to those specified to the
|
||||
* {@code run} methods. Default arguments can always be overridden by user defined
|
||||
* arguments..
|
||||
* @param defaultArgs the default args to set
|
||||
*/
|
||||
public void setDefaultCommandLineArgs(String... defaultCommandLineArgs) {
|
||||
this.defaultCommandLineArgs = defaultCommandLineArgs;
|
||||
public void setDefaultArgs(String... defaultArgs) {
|
||||
this.defaultArgs = defaultArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -315,7 +315,7 @@ public class SpringApplicationTests {
|
||||
@Test
|
||||
public void defaultCommandLineArgs() throws Exception {
|
||||
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
||||
application.setDefaultCommandLineArgs("--baz", "--bar=spam", "bucket");
|
||||
application.setDefaultArgs("--baz", "--bar=spam", "bucket");
|
||||
application.setWebEnvironment(false);
|
||||
this.context = application.run("--bar=foo", "bucket", "crap");
|
||||
assertThat(this.context, instanceOf(AnnotationConfigApplicationContext.class));
|
||||
|
||||
Reference in New Issue
Block a user