Browse Source

Rename SpringApplication.defaultCommandLineArgs

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

Issue: #55202844
pull/28/head
Phillip Webb 13 years ago
parent
commit
e1cea7dca9
  1. 18
      spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
  2. 2
      spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java

18
spring-boot/src/main/java/org/springframework/boot/SpringApplication.java

@ -162,7 +162,7 @@ public class SpringApplication { @@ -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 { @@ -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 { @@ -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;
}
/**

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

@ -315,7 +315,7 @@ public class SpringApplicationTests { @@ -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));

Loading…
Cancel
Save