[JBoss] Get build timestamp on JBoss application

Discussão em 'StackOverflow' iniciado por Stack, Setembro 3, 2021.

  1. Stack

    Stack Membro Participativo

    We have a web application on JBoss 7.2. Now I want to display the build timestamp in my UI for debugging purposes, so I added

    • a properties file looking like that:

    version=${pom.version}
    build.date=${timestamp}

    • in the POM properties:

    <properties>
    <timestamp>${maven.build.timestamp}</timestamp>
    <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
    </properties>


    On build, this successfully generates a .properties file with the correct values, e.g.

    version=0.1-SNAPSHOT
    build.date=2021-08-25 12:00


    However, when deployed, that properties file isn't available anymore. I get a FileNotFoundException when my frontend bean tries to access the file via

    String propertyPath = "src/main/resources/version.properties";
    try (InputStream properties = new FileInputStream(propertyPath)) {

    Properties prop = new Properties();
    prop.load(properties);
    }
    ...


    Now of course I can add the properties to my standalone.xml, but I wasn't able to replace the values during build time. Any tips on how to make it work?

    Continue reading...

Compartilhe esta Página