Some of the banner properties not populated when running with unpacked jar and custom banner
When running Spring Boot application with custom banner and unpacked jar as documented in [1], the following banner properties that described in [2] are not printed
- application.version
- application.formatted-version
- application.title
Spring Boot version: 2.3.1.RELEASE
i saw this #21705 that looks similar issue, but i tried with 2.3.1.RELEASE version and it still does not show the values.
Example project that re-create the issue
Comment From: wilkinsona
Thanks for the sample. The problem is as @philwebb described here. The change made in #21705 has not helped in your case as you are not using Spring Boot's launcher. This means that it doesn't get a chance to make it possible to load a manifest (which is the source of the application version) from a folder.
You can avoid the problem by unpacking the jar and then using JarLauncher
to start the app:
$ java -cp . org.springframework.boot.loader.JarLauncher
DEMO BANNER START
application version = 0.0.1-SNAPSHOT
application formatted version = (v0.0.1-SNAPSHOT)
spring-boot version = 2.3.1.RELEASE
spring-boot formatted version = (v2.3.1.RELEASE)
application title = demo-banner
DEMO BANNER END
2020-07-23 09:41:21.631 INFO 2004 --- [ main] c.e.demobanner.DemoBannerApplication : Starting DemoBannerApplication v0.0.1-SNAPSHOT on fulcrum.local with PID 2004 (/Users/awilkinson/dev/temp/demo-banner/target/unpacked/BOOT-INF/classes started by awilkinson in /Users/awilkinson/dev/temp/demo-banner/target/unpacked)
2020-07-23 09:41:21.633 INFO 2004 --- [ main] c.e.demobanner.DemoBannerApplication : No active profile set, falling back to default profiles: default
2020-07-23 09:41:21.992 INFO 2004 --- [ main] c.e.demobanner.DemoBannerApplication : Started DemoBannerApplication in 0.598 seconds (JVM running for 0.866)
=== demo banner application ===
I don't think there's anything we can do to improve this behaviour. When launched with a classpath of BOOT-INF/classes
and BOOT-INF/lib/*.jar
the manifest isn't even on the classpath so there's no reliable way for us to find it.
Let's update the banner customization documentation to note the restriction and recommend the use of the launcher with an exploded archive.
Comment From: wilkinsona
Another option is to set the application.version
and application.title
properties in application.properties
. You can use placeholders to get the values from the Maven project:
application.version=@project.version@
application.title=@project.name@
Comment From: orenw1
@wilkinsona, thank you for the answer and suggestion!
Comment From: robert-smith-911
@wilkinsona I know this is an oldie, but mind if I update the docs for this one?
Comment From: philwebb
Closing in favor of PR #24982. Thanks @robert-smith-911!
Comment From: wilkinsona
Sorry for missing your question about updating the docs, @robert-smith-911. Thanks for opening a PR despite my lack of response.
Comment From: robert-smith-911
@wilkinsona You're welcome!