java - How to get package version at running Tomcat? -



java - How to get package version at running Tomcat? -

how bundle version @ running tomcat?

i seek getclass().getpackage().getimplementationversion() returns null. guess because war wasn't yet packaged , tomcat executes .classes (aka exploded war). meta-inf\manifest.mf nowadays in final war, not in target\<project.name>\meta-inf folder

java.lang.package

package objects contain version info implementation , specification of java package. versioning info retrieved , made available classloader instance loaded class(es). typically, stored in manifest distributed classes.

related how maven artifact version @ runtime?

update. before have added configuration war build. when running tomcat eclipse, null.

<plugin> <artifactid>maven-war-plugin</artifactid> <version>2.1</version> <configuration> <archive> <manifest> <adddefaultimplementationentries>true</adddefaultimplementationentries> <adddefaultspecificationentries>true</adddefaultspecificationentries> </manifest> </archive> <!-- moves classes \web-inf\classes new jar <archiveclasses>true</archiveclasses> --> </configuration> </plugin>

solved by 1) creating meta-inf\manifest.mf in webapp folder mvn war:manifest 2) coding

version = getclass().getpackage().getimplementationversion(); if (version==null) { properties prop = new properties(); seek { prop.load(getservletcontext().getresourceasstream("/meta-inf/manifest.mf")); version = prop.getproperty("implementation-version"); } grab (ioexception e) { logger.error(e.tostring()); } } logger.info("starting app version "+version);

thanks @javadude reply @ how read manifest file webapp running in apache tomcat?

java eclipse maven tomcat manifest.mf

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -