I try to get Attributes out of MANIFEST.MF in my war file. I work with Spring-MVC. I modified the manifest file with the maven war plugin and added build numbers and build date.
Now i want to get those attributes from the manifest file. I searched a lot in the internet and on stackoverflow and found a lot of things. I tried almost everything and nothing works. Thats why i try to find help here now.
That is my code:
@RequestMapping(value="/infos",method = RequestMethod.GET)
@ResponseBody
public String getVersion(HttpServletRequest req) {
String version = "";
try {
InputStream stream = this.getClass().getClassLoader().getResourceAsStream("META-INF/MANIFEST.MF");
Manifest manifest = new Manifest(stream);
Attributes attributes = manifest.getMainAttributes();
version = attributes.getValue("Implementation-Version");
} catch (Exception e) {
e.printStackTrace();
}
return version;
}
The location of my manifest file is the following: .war/META-INF/MANIFEST.MF
This is what i get when i look with the debugger in the attributes:
I get the wrong manifest file but i dont know how to get the right one. I thought it have something to do with the classloader...