How can I in a jsp page get maven project version number?

后端 未结 11 2220
天命终不由人
天命终不由人 2020-12-14 16:07

I am working on a java web application, managed by maven2. From time to time, we did some changes, and want to do new releases, of course with new version number. In the hom

11条回答
  •  死守一世寂寞
    2020-12-14 16:58

    I would hand the .jsp the value of

    String version = getClass().getPackage().getImplementationVersion();
    

    that would look like 1.0.0-SNAPSHOT for instance.

    If you are just getting nulls, you may need to add the classpath to the Manifest of the war with

    
        org.apache.maven.plugins
        maven-war-plugin
        2.5
        
            
                
                    true
                
            
        
    
    

    for the classloader to pick it up.

提交回复
热议问题