I'm trying to display the application version of my Spring Boot application in a view. I'm sure I can access this version information, I just don't know how.
I tried following this information: https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html, and put this in my application.properties
:
info.build.version=${version}
And then loading it @Value("${version.test}")
in my controller, but that doesn't work, I only get errors like:
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'version' in string value "${version}"
Any suggestions on what the proper way to get information like my app version, the spring boot version, etc into my controller?
You are going to need to update gradle, as newer spring boot versions are incompatible with older versions of gradle. You can either download the new gradle manually or use gradle wrapper to set the version for your project.
In Android Studio, go to File > Project Structure. Then select the "project" tab on the left. Your Gradle version will be displayed here.
Clean & Build Gradle Spring Boot Application It will create jar file at \build\libs.
Introduction. The Spring Boot Gradle Plugin provides Spring Boot support in Gradle. It allows you to package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by spring-boot-dependencies . Spring Boot's Gradle plugin requires Gradle 6.8, 6.9, or 7.
You can also add this in build.gradle
:
springBoot { buildInfo() }
Then, you can use BuildProperties
bean :
@Autowired private BuildProperties buildProperties;
And get the version with buildProperties.getVersion()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With