Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot Banner reporting wrong java version

At the bottom of our banner.txt, we have the following

Running Spring Boot ${spring-boot.version} on java ${java.version} in environment ${ccic.environ}

which starts up with

Running Spring Boot 2.0.5.RELEASE on java 1.8.0_144 in environment uat

We had a bit of a scare today because someone noticed it says 1.8.0_144 for the java.version, however we should be running 1.8.0_131. After further investigation, we can confirm that we are running with 1.8.0_131.

I was curious where 1.8.0_144 was coming from. It seems MANIFEST.MF contains the value of 1.8.0_144 for the key Build-Jdk, presumably java on the build server is wrong. Is that were spring is reading it from?

It surprises me that java.version would prefer MANIFEST.MF over the runtime. Am I off in my thinking? Why is spring boot not returning the correct java version? I tried looking in the spring source, but finding "java.version" or "javaversion" hasn't been helpful.

like image 281
pgreen2 Avatar asked Sep 01 '25 10:09

pgreen2


1 Answers

It turns out the MANIFEST.MF and spring were both red herrings. We use maven for our builds and we had filtering turned on. The builds were filtering banner.txt and replacing the value. We used the following configuration to prevent the filtering from occurring to banner.txt.

        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <excludes>
                <exclude>banner.txt</exclude>
            </excludes>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>false</filtering>
            <includes>
                <include>banner.txt</include>
            </includes>
        </resource>
like image 153
pgreen2 Avatar answered Sep 03 '25 00:09

pgreen2