Vaadin, Spring Boot and static resources?


unsure whether this is a question too basic (apologize if so): Being into moving a modestly large Vaading (war-packed) application to Spring Boot, I am amazed to see things move along pretty smoothly, but I so far didn’t manage to get our static items, such as icons and stylesheets (which, in the .war world, live in src/main/webapp/VAADIN/themes) into the Spring Boot application. Can anyone enlighten me how Spring Boot needs to be configured / where these files need to be placed in order to actually have them accessible at runtime?

TIA and all the best,

Vaadin will find those from classpath as well, so adding that stuff to src/main/resources/VAADIN/… should do fine. Spring boot also has this “static” directory, but it might be hard to reference that stuff past Vaadin servlet. Works if you map vaadin servlet to a different location.



I also have a Vaadin Spring boot application (generating a jar file), however when I try to read a static file using:

String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath(); new File(basepath + "/navigation.xml"); I get the following error during runtime, which is correct, because the file is in /src/main/resources and not in webapp.:
C:\Projects\xxx\src\main\webapp\navigation.xml (System cannot find the file)

Starting the application from Eclipse via

vaadin:compile spring-boot:run

Where is the configuration coming from that vaadin tries to search in the webapp folder?
Any hint would be appreciated.


        <relativePath /> <!-- lookup parent from repository -->













        <!-- For widgetset compilation, vaadin-client-compiler is automatically
            added on the compilation classpath by vaadin-maven-plugin so normally there
            is no need for an explicit dependency. <dependency> <groupId>com.vaadin</groupId>
            <artifactId>vaadin-client-compiler</artifactId> </dependency> -->

                    <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
                    <!-- We are doing "inplace" but into subdir VAADIN/widgetsets. This
                        way compatible with Vaadin eclipse plugin.  -->
                            <!--<goal>update-theme</goal> -->
                            <!-- disabled by default to use on-the-fly theme compilation -->
                            <!-- <goal>compile-theme</goal> -->



I’d suggest to put your resource to src/resources/ and then access it from classpath:

getClass().getResourceAsStream("/yourresource.xml") cheers,

Posted this post also to!/thread/9721905 which was the other post I found when investigating the issue of Vaadin with Spring Boot and custom themes.

Am posting this in case it helps anyone. Had a real problem with getting Vaadin custom themes to work with Spring Boot with a Jar deployment. The application worked fine in development in Intellij but when deployed to AWS no themes. The src/main/webapp folder wasn’t making it to the deployment Jar. I tried putting the webapp/VAADIN and just the VAADIN folder in /src/main/resources/, as per Spring Boot docs but that didn’t work either. Vaadin wasn’t finding the themes.

After a lot of experimenting with various Maven plugins, the following is currently working well. In the pom.xml, in the section (where you also define for spring-boot-maven-plugin and vaadin-maven-plugin), just add:

<resources> <resource> <directory>src/main/webapp</directory> </resource> </resources> One concern is that the Spring Boot docs ( explicitly tell you “Do not use the src/main/webapp directory if your application will be packaged as a jar. Although this directory is a common standard, it will only work with war packaging and it will be silently ignored by most build tools if you generate a jar.” I am hoping there are no negative consequences if you force src/main/webapp to be included.

The Vaadin docs say that “Custom themes are placed under the VAADIN/themes/ folder of the web application (under WebContent in Eclipse or src/main/webapp in Maven projects). This location is fixed” Perhaps Vaadin should allow a bit more flexibility for custom themes to be placed in the resources directory.

Give Vaadin 7.7 a try, it vastly improves Spring Boot integration. Themes in src/main/resources are now supported, among other things. Theme compilation also works without further configuration.

Does one create a webapp/VAADIN folder under src/main/resources/static?


@Jo src/main/resources/VAADIN is what I use