vendredi 27 mai 2016

WarLauncher in SpringBoot does not read external resources

I have a SpringBoot application that should be able to read some external files from a S.O. folder.

Creating a JAR build, I can use the VM parameter "-Dloader.path" and set the folder where the external files will be, and after that the application reads them via classpath loader.

Sadly my SpringBoot application is WEB, because there are pictures, jsp that should be in WAR format and read them via ServletContext.

Using the JAR format the build is created using PropertiesLauncher to load the application, and WAR format uses WarLauncher. PropertiesLauncher is able to read external folders, but WarLauncher is not.

Is there any way to inform the WAR about those external folders? Some kind of VM parameter, or even a property for it.

It would be nice to have some kind of launcher that mixes WAR with JAR features for class loading resources.

By the way, the JAR format uses ZIP layout on MAVEN to work, but WAR does not accept this layout giving error about the directory.

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <layout>ZIP</layout>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>               
</plugin>




Aucun commentaire:

Enregistrer un commentaire