Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

info endpoint - application.yml maven filtering not working

Tags:

spring-boot

We are using spring boot 1.3.1. I have following details in my application.yml file.

info:
  build:
    artifact: ${project.artifactId}
    name: ${project.name}
    description: ${project.description}
    version: ${project.version}

I am building the war file and deploying it to tomcat. When I access /info endpoint, i don't see values are substituted.

I am not using 'spring-boot-maven-plugin' as i don't need to run the application standalone.

Does the filtering work for YML files by default?

Also, is there any example of showing application version on banner.txt file using maven project.version property?


After Dave's comment, I updated my application.yml file as shown below and it is working.

info:
  build:
    artifact: @project.artifactId@
    name: @project.name@
    description: @project.description@
    version: @project.version@

Also, I found that application.version is not picked up in standalone tomcat for banner.txt file. Tomcat fails to read manifest.mf file. Spring boot issue: https://github.com/spring-projects/spring-boot/issues/3406

like image 939
Ketan Avatar asked Jan 26 '16 15:01

Ketan


2 Answers

I don't think filtering is switched on in maven by default. If you use the spring-boot-starter-parent it is enabled, but the key for the placeholders is @..@ not ${..}.

like image 60
Dave Syer Avatar answered Sep 27 '22 18:09

Dave Syer


I don't know which version of spring boot you are using,

But for me version: @project.version@ did not work. Instead version: #project.version# worked for me.

My project is having following parent pom config :

<parent>
    <artifactId>spring-boot-starter-parent</artifactId>
    <groupId>org.springframework.boot</groupId>
    <version>1.4.1.RELEASE</version>
    <relativePath />
</parent>
like image 38
Anil Bharadia Avatar answered Sep 27 '22 18:09

Anil Bharadia