Search code examples
springmavenjbosswildflywar

How to externalise .properties files when deploying a Spring Boot WAR in Wildfly Server?


I am developing a web application using Spring Boot, and want to generate war instead of jar. It works fine using the conversion from jar to war described here : http://spring.io/guides/gs/convert-jar-to-war/

But I want to externalize the application.properties from the war, because I want to be able to modify it without opening the war archive.

I already defined the spring-boot-maven plugin.

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
            <configuration>
                <classifier>spring-boot</classifier>
                <mainClass>
                  com.application.Application
                </mainClass>
            </configuration>
        </execution>
    </executions>
</plugin>

I think I need to add Dependency: config to my manifest file. So, I've done it like that :

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
            <archive>
                <manifestEntries>
                    <Dependencies>config</Dependencies>
                </manifestEntries>
            </archive>
        </configuration>
    </plugin>

But when I launch the Application.war on Wildfly 8.4, I've got this

{"JBAS014671: Failed services" => {"jboss.module.service.\"deployment.Application.war\".main" => "org.jboss.msc.service.StartException in service jboss.module.service.\"deployment.screening.war\".main: JBAS018759: Failed to load module: deployment.Application.war:main
    Caused by: org.jboss.modules.ModuleNotFoundException: config:main"}}

I would like that my application start with my custom MANIFEST.MF (with Dependency: config) so that I can externalize my application.properties file.

Thank you.


Solution

  • The problem was on the server side !

    When you specify a package, you need to add a module.xml file with a Wildfly server.

    So in modules/config/main/, I've added my application.properties and a module.xml file that contains :

    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.1" name="config">
        <resources>
            <resource-root path="."/>
        </resources>
    </module>
    

    Thank you for your response @NielsNet.