javaspring-bootdeploymentpom.xmljboss-web

Jboss-web.xml for different enviroments


For my spring boot microservice, how could I have different versions of Jboss-web.xml configured for development and production. I need this because the security-domain and valve tags apply for production but not development. Hence, I need to either disable these two tags for development or have separate jboss-web.xml for dev and prod environment and have the right file picked up based on the profile or environment. Please advise.


Solution

  • You can organize your resources (src/main/resources) by environment:

    Resources by environmet

    In the build tag from pom.xml enable filtering by environment:

    <resource>
        <directory>src/main/resources/${environment}/app-context</directory>
            <filtering>false</filtering>
            <includes>
                <include>*</include>
            </includes>
        <targetPath>${project.build.directory}/${warName}/WEB-INF</targetPath>
    </resource>
    

    And execute by command line with this:

    mvn clean install -Denvironment="development"
    

    More details in maven reference: https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html