How to read MANIFEST.MF inside WAR application?

前端 未结 4 1510
执笔经年
执笔经年 2021-02-04 07:07

I would like to read MANIFEST.MF of my WAR application. How can I find its file name?

4条回答
  •  野性不改
    2021-02-04 07:53

    There are a few ways to do it, and the chosen answer is only works when you want to read Manifiest files on Servlet/SpringMVC layer or whatever layer you can access to ServletContext.

    However, if you want to read a value like "version" even before Servlet starts up, like during logback configuration or something else, you might need to do some old-way classloading or Manifest file manipulation.

    I found this github repository(not mine) and it includes 4 different way to read information from Manifest file. If your situation is not accessible to ServletContext, check these out.

    https://github.com/khmarbaise/version-examples

提交回复
热议问题