Display version and build date on xhtml page

I want to display the build version and build date on the footer of a JSF application. XHTML Pages. I am looking for ways to get information from pom.xml or other artifacts.

I found the following that uses the maven-replace plugin. http://www.vineetmanohar.com/2010/09/how-to-display-maven-project-version-in-your-webapp/

Are there any other methods that you use?

I'm looking for something similar with JSF - Display build date

+5
source share
1 answer

, : Maven WAR JAR, . - Java ClassPath InputStream.

(, "buildInfo.properties" ) src/main/resources, - :

build.version=${project.version}
build.timestamp=${timestamp}

, - timestamp <properties> pom:

`<timestamp>${maven.build.timestamp}</timestamp>`

project.version( <version> pom.xml,

 <resources>
   <resource>
     <directory>src/main/resources</directory>
     <filtering>true</filtering>
   </resource>
 </resources>

Java- (JSF bean, ), :

    InputStream in = getClass().getClassLoader().getResourceAsStream("buildInfo.properties");
    if (in == null)
        return;

    Properties props = new Properties();
    props.load(in);

    String version = props.getProperty("build.version");
    // etc.

" " (, Spring), Java-, .

+12

All Articles