diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CrshAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CrshAutoConfiguration.java index 653934af158..6b52a539474 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CrshAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CrshAutoConfiguration.java @@ -61,6 +61,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.SpringVersion; +import org.springframework.core.env.Environment; import org.springframework.core.io.Resource; import org.springframework.core.io.support.ResourcePatternResolver; import org.springframework.security.access.AccessDecisionManager; @@ -198,6 +199,9 @@ public class CrshAutoConfiguration { @Autowired private ListableBeanFactory beanFactory; + @Autowired + private Environment environment; + @Autowired private ShellProperties properties; @@ -250,6 +254,9 @@ public class CrshAutoConfiguration { if (this.beanFactory != null) { attributes.put("spring.beanfactory", this.beanFactory); } + if (this.environment != null) { + attributes.put("spring.environment", this.environment); + } return attributes; } diff --git a/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index 855c7520b91..e5af8d86ea8 100644 --- a/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -533,8 +533,11 @@ from your command: |`spring.version` |The version of the core Spring Framework -|`spring.beanFactory` +|`spring.beanfactory` |Access to the Spring `BeanFactory` + +|`spring.environment` +|Access to the Spring `Environment` |=== diff --git a/spring-boot-starters/spring-boot-starter-shell/src/main/resources/commands/crash/login.groovy b/spring-boot-starters/spring-boot-starter-shell/src/main/resources/commands/crash/login.groovy index 21d4dc5b65a..a192dcd951a 100644 --- a/spring-boot-starters/spring-boot-starter-shell/src/main/resources/commands/crash/login.groovy +++ b/spring-boot-starters/spring-boot-starter-shell/src/main/resources/commands/crash/login.groovy @@ -1,11 +1,19 @@ welcome = { -> + if (!crash.context.attributes['spring.environment'].getProperty("spring.main.show_banner", Boolean.class, Boolean.TRUE)) { + return "" + } + + // Resolve hostname def hostName; try { hostName = java.net.InetAddress.getLocalHost().getHostName(); } catch (java.net.UnknownHostException ignore) { hostName = "localhost"; } + + // Get Spring Boot version from context def version = crash.context.attributes.get("spring.boot.version") + return """\ . ____ _ __ _ _ /\\\\ / ___'_ __ _ _(_)_ __ __ _ \\ \\ \\ \\