parent
e9c69aa46f
commit
133304c4f7
|
|
@ -139,6 +139,7 @@ import org.springframework.web.context.support.StandardServletEnvironment;
|
|||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
* @author Andy Wilkinson
|
||||
* @author Christian Dupuis
|
||||
* @see #run(Object, String[])
|
||||
* @see #run(Object[], String[])
|
||||
* @see #SpringApplication(Object...)
|
||||
|
|
@ -152,7 +153,7 @@ public class SpringApplication {
|
|||
+ "boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext";
|
||||
|
||||
private static final String[] WEB_ENVIRONMENT_CLASSES = { "javax.servlet.Servlet",
|
||||
"org.springframework.web.context.ConfigurableWebApplicationContext" };
|
||||
"org.springframework.web.context.ConfigurableWebApplicationContext" };
|
||||
|
||||
private static final String SYSTEM_PROPERTY_JAVA_AWT_HEADLESS = "java.awt.headless";
|
||||
|
||||
|
|
@ -478,10 +479,11 @@ public class SpringApplication {
|
|||
Resource resource = resourceLoader.getResource(location);
|
||||
if (resource.exists()) {
|
||||
try {
|
||||
System.out.println(StreamUtils.copyToString(
|
||||
String banner = StreamUtils.copyToString(
|
||||
resource.getInputStream(),
|
||||
environment.getProperty("banner.charset", Charset.class,
|
||||
Charset.forName("UTF-8"))));
|
||||
Charset.forName("UTF-8")));
|
||||
System.out.println(environment.resolvePlaceholders(banner));
|
||||
return;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
|
@ -546,7 +548,7 @@ public class SpringApplication {
|
|||
if (this.resourceLoader != null) {
|
||||
if (context instanceof GenericApplicationContext) {
|
||||
((GenericApplicationContext) context)
|
||||
.setResourceLoader(this.resourceLoader);
|
||||
.setResourceLoader(this.resourceLoader);
|
||||
}
|
||||
if (context instanceof DefaultResourceLoader) {
|
||||
((DefaultResourceLoader) context).setClassLoader(this.resourceLoader
|
||||
|
|
@ -579,7 +581,7 @@ public class SpringApplication {
|
|||
protected void logStartupInfo(boolean isRoot) {
|
||||
if (isRoot) {
|
||||
new StartupInfoLogger(this.mainApplicationClass)
|
||||
.logStarting(getApplicationLog());
|
||||
.logStarting(getApplicationLog());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ import static org.mockito.Mockito.verify;
|
|||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
* @author Andy Wilkinson
|
||||
* @author Christian Dupuis
|
||||
*/
|
||||
public class SpringApplicationTests {
|
||||
|
||||
|
|
@ -162,6 +163,15 @@ public class SpringApplicationTests {
|
|||
verify(application, never()).printBanner();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customBannerWithProperties() throws Exception {
|
||||
SpringApplication application = spy(new SpringApplication(ExampleConfig.class));
|
||||
application.setWebEnvironment(false);
|
||||
application.run("--banner.location=classpath:test-banner-with-placeholder.txt",
|
||||
"--test.property=123456");
|
||||
verify(application, never()).printBanner();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customId() throws Exception {
|
||||
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
Running a Test!
|
||||
|
||||
${test.property}
|
||||
Loading…
Reference in New Issue