How to read my META-INF/MANIFEST.MF file in a Spring Boot app?

后端 未结 7 1424
后悔当初
后悔当初 2020-12-30 02:31

I\'m trying to read my META-INF/MANIFEST.MF file from my Spring Boot web app (contained in a jar file).

I\'m trying the following code:

        Input         


        
7条回答
  •  无人及你
    2020-12-30 02:56

    I use java.lang.Package to read the Implementation-Version attribute in spring boot from the manifest.

    String version = Application.class.getPackage().getImplementationVersion();
    

    The Implementation-Version attribute should be configured in build.gradle

    jar {
        baseName = "my-app"
        version =  "0.0.1"
        manifest {
            attributes("Implementation-Version": version)
        }
    }
    

提交回复
热议问题