Commit 76bda7e3 authored by Phillip Webb's avatar Phillip Webb Committed by Phillip Webb

Rename SpringApplication.defaultCommandLineArgs

Rename SpringApplication.defaultCommandLineArgs to defaultArgs for
consistency with the run() method arguments.

Issue: #55202844
parent 5b77028f
...@@ -162,7 +162,7 @@ public class SpringApplication { ...@@ -162,7 +162,7 @@ public class SpringApplication {
private List<ApplicationContextInitializer<?>> initializers; private List<ApplicationContextInitializer<?>> initializers;
private String[] defaultCommandLineArgs; private String[] defaultArgs;
/** /**
* Crate a new {@link SpringApplication} instance. The application context will load * Crate a new {@link SpringApplication} instance. The application context will load
...@@ -312,10 +312,10 @@ public class SpringApplication { ...@@ -312,10 +312,10 @@ public class SpringApplication {
*/ */
protected void addPropertySources(ConfigurableEnvironment environment, String[] args) { protected void addPropertySources(ConfigurableEnvironment environment, String[] args) {
if (this.addCommandLineProperties) { if (this.addCommandLineProperties) {
if (this.defaultCommandLineArgs != null) { if (this.defaultArgs != null) {
environment.getPropertySources().addFirst( environment.getPropertySources().addFirst(
new SimpleCommandLinePropertySource("defaultCommandLineArgs", new SimpleCommandLinePropertySource("defaultCommandLineArgs",
this.defaultCommandLineArgs)); this.defaultArgs));
} }
environment.getPropertySources().addFirst( environment.getPropertySources().addFirst(
new SimpleCommandLinePropertySource(args)); new SimpleCommandLinePropertySource(args));
...@@ -543,13 +543,13 @@ public class SpringApplication { ...@@ -543,13 +543,13 @@ public class SpringApplication {
} }
/** /**
* Set default command line arguments which will be used in addition to those * Set default arguments which will be used in addition to those specified to the
* specified to the {@code run} methods. Default arguments can always be overridden by * {@code run} methods. Default arguments can always be overridden by user defined
* user defined arguments.. * arguments..
* @param defaultCommandLineArgs the default command line args to set * @param defaultArgs the default args to set
*/ */
public void setDefaultCommandLineArgs(String... defaultCommandLineArgs) { public void setDefaultArgs(String... defaultArgs) {
this.defaultCommandLineArgs = defaultCommandLineArgs; this.defaultArgs = defaultArgs;
} }
/** /**
......
...@@ -315,7 +315,7 @@ public class SpringApplicationTests { ...@@ -315,7 +315,7 @@ public class SpringApplicationTests {
@Test @Test
public void defaultCommandLineArgs() throws Exception { public void defaultCommandLineArgs() throws Exception {
SpringApplication application = new SpringApplication(ExampleConfig.class); SpringApplication application = new SpringApplication(ExampleConfig.class);
application.setDefaultCommandLineArgs("--baz", "--bar=spam", "bucket"); application.setDefaultArgs("--baz", "--bar=spam", "bucket");
application.setWebEnvironment(false); application.setWebEnvironment(false);
this.context = application.run("--bar=foo", "bucket", "crap"); this.context = application.run("--bar=foo", "bucket", "crap");
assertThat(this.context, instanceOf(AnnotationConfigApplicationContext.class)); assertThat(this.context, instanceOf(AnnotationConfigApplicationContext.class));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment