|
|
@ -139,6 +139,7 @@ import org.springframework.web.context.support.StandardServletEnvironment;
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
* @author Jeremy Rickard
|
|
|
|
* @author Jeremy Rickard
|
|
|
|
* @author Craig Burke
|
|
|
|
* @author Craig Burke
|
|
|
|
|
|
|
|
* @author Michael Simons
|
|
|
|
* @see #run(Object, String[])
|
|
|
|
* @see #run(Object, String[])
|
|
|
|
* @see #run(Object[], String[])
|
|
|
|
* @see #run(Object[], String[])
|
|
|
|
* @see #SpringApplication(Object...)
|
|
|
|
* @see #SpringApplication(Object...)
|
|
|
@ -200,6 +201,8 @@ public class SpringApplication {
|
|
|
|
|
|
|
|
|
|
|
|
private Banner banner;
|
|
|
|
private Banner banner;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean printedCustomBannerViaDeprecatedMethod;
|
|
|
|
|
|
|
|
|
|
|
|
private ResourceLoader resourceLoader;
|
|
|
|
private ResourceLoader resourceLoader;
|
|
|
|
|
|
|
|
|
|
|
|
private BeanNameGenerator beanNameGenerator;
|
|
|
|
private BeanNameGenerator beanNameGenerator;
|
|
|
@ -304,11 +307,10 @@ public class SpringApplication {
|
|
|
|
args);
|
|
|
|
args);
|
|
|
|
ConfigurableEnvironment environment = prepareEnvironment(listeners,
|
|
|
|
ConfigurableEnvironment environment = prepareEnvironment(listeners,
|
|
|
|
applicationArguments);
|
|
|
|
applicationArguments);
|
|
|
|
if (this.bannerMode != Banner.Mode.OFF) {
|
|
|
|
Banner printedBanner = printBanner(environment);
|
|
|
|
printBanner(environment);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
context = createApplicationContext();
|
|
|
|
context = createApplicationContext();
|
|
|
|
prepareContext(context, environment, listeners, applicationArguments);
|
|
|
|
prepareContext(context, environment, listeners, applicationArguments,
|
|
|
|
|
|
|
|
printedBanner);
|
|
|
|
refreshContext(context);
|
|
|
|
refreshContext(context);
|
|
|
|
afterRefresh(context, applicationArguments);
|
|
|
|
afterRefresh(context, applicationArguments);
|
|
|
|
listeners.finished(context, null);
|
|
|
|
listeners.finished(context, null);
|
|
|
@ -340,7 +342,7 @@ public class SpringApplication {
|
|
|
|
|
|
|
|
|
|
|
|
private void prepareContext(ConfigurableApplicationContext context,
|
|
|
|
private void prepareContext(ConfigurableApplicationContext context,
|
|
|
|
ConfigurableEnvironment environment, SpringApplicationRunListeners listeners,
|
|
|
|
ConfigurableEnvironment environment, SpringApplicationRunListeners listeners,
|
|
|
|
ApplicationArguments applicationArguments) {
|
|
|
|
ApplicationArguments applicationArguments, Banner printedBanner) {
|
|
|
|
context.setEnvironment(environment);
|
|
|
|
context.setEnvironment(environment);
|
|
|
|
postProcessApplicationContext(context);
|
|
|
|
postProcessApplicationContext(context);
|
|
|
|
applyInitializers(context);
|
|
|
|
applyInitializers(context);
|
|
|
@ -353,6 +355,9 @@ public class SpringApplication {
|
|
|
|
// Add boot specific singleton beans
|
|
|
|
// Add boot specific singleton beans
|
|
|
|
context.getBeanFactory().registerSingleton("springApplicationArguments",
|
|
|
|
context.getBeanFactory().registerSingleton("springApplicationArguments",
|
|
|
|
applicationArguments);
|
|
|
|
applicationArguments);
|
|
|
|
|
|
|
|
if (printedBanner != null) {
|
|
|
|
|
|
|
|
context.getBeanFactory().registerSingleton("springBootBanner", printedBanner);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Load the sources
|
|
|
|
// Load the sources
|
|
|
|
Set<Object> sources = getSources();
|
|
|
|
Set<Object> sources = getSources();
|
|
|
@ -530,6 +535,29 @@ public class SpringApplication {
|
|
|
|
environment.setActiveProfiles(profiles.toArray(new String[profiles.size()]));
|
|
|
|
environment.setActiveProfiles(profiles.toArray(new String[profiles.size()]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Banner printBanner(ConfigurableEnvironment environment) {
|
|
|
|
|
|
|
|
if (printBannerViaDeprecatedMethod(environment)) {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.bannerMode == Banner.Mode.OFF) {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ResourceLoader resourceLoader = this.resourceLoader != null ? this.resourceLoader
|
|
|
|
|
|
|
|
: new DefaultResourceLoader(getClassLoader());
|
|
|
|
|
|
|
|
SpringApplicationBannerPrinter bannerPrinter = new SpringApplicationBannerPrinter(
|
|
|
|
|
|
|
|
resourceLoader, this.banner);
|
|
|
|
|
|
|
|
if (this.bannerMode == Mode.LOG) {
|
|
|
|
|
|
|
|
return bannerPrinter.print(environment, this.mainApplicationClass, logger);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return bannerPrinter.print(environment, this.mainApplicationClass, System.out);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean printBannerViaDeprecatedMethod(Environment environment) {
|
|
|
|
|
|
|
|
this.printedCustomBannerViaDeprecatedMethod = true;
|
|
|
|
|
|
|
|
printBanner(environment);
|
|
|
|
|
|
|
|
return this.printedCustomBannerViaDeprecatedMethod;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Print a custom banner message to the console, optionally extracting its location or
|
|
|
|
* Print a custom banner message to the console, optionally extracting its location or
|
|
|
|
* content from the Environment (banner.location and banner.charset). The defaults are
|
|
|
|
* content from the Environment (banner.location and banner.charset). The defaults are
|
|
|
@ -537,18 +565,11 @@ public class SpringApplication {
|
|
|
|
* not exist or cannot be printed, a simple default is created.
|
|
|
|
* not exist or cannot be printed, a simple default is created.
|
|
|
|
* @param environment the environment
|
|
|
|
* @param environment the environment
|
|
|
|
* @see #setBannerMode
|
|
|
|
* @see #setBannerMode
|
|
|
|
|
|
|
|
* @deprecated as of 1.4 in favor of @{@link #setBanner(Banner)}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Deprecated
|
|
|
|
protected void printBanner(Environment environment) {
|
|
|
|
protected void printBanner(Environment environment) {
|
|
|
|
ResourceLoader resourceLoader = this.resourceLoader != null ? this.resourceLoader
|
|
|
|
this.printedCustomBannerViaDeprecatedMethod = false;
|
|
|
|
: new DefaultResourceLoader(getClassLoader());
|
|
|
|
|
|
|
|
SpringApplicationBannerPrinter banner = new SpringApplicationBannerPrinter(resourceLoader,
|
|
|
|
|
|
|
|
this.banner);
|
|
|
|
|
|
|
|
if (this.bannerMode == Mode.LOG) {
|
|
|
|
|
|
|
|
banner.print(environment, this.mainApplicationClass, logger);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
banner.print(environment, this.mainApplicationClass, System.out);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|