Spring Boot is a framework that provides auto configuration capabilities to quickly package and deploy Spring ecosystem based applications. It allows developers to focus the core function of their application, rather than spending time on configuration and project set up. Spring Boot is meant for Spring framework based applications but it can also integrate with other frameworks and utilities. Spring Boot provides integration with Vaadin, which is partly based on GWT. GWT can also effortlessly integrate into a Spring Boot application, with the right configuration in place. In this tutorial, we will go through how to integrate GWT into a SB application, and how to run the GWT dev mode on SB’s embeded web server.

The first step is to generate a SB project. In this tutorial, we will make use of INITIALIZR, which is Spring’s tool for quickly bootstrapping projects. For this project, we will only need the Web dependency.

initialzr

The structure of the generated project is a standard maven project structure.

bootFileStrucutre

One of the SB conventions to keep in mind is that files present in the resources/static directory are treated as static resources, and served by SB embedded server. Since we need our GWT project(HTML, CSS + our Js module) to be served as static resources, we need to put them in the static folder. However, when running spring-boot “locally”, the static files that our app uses are copied to the build directory, within the classes folder (normally the path is stored in project.build.directory property in Maven, which points to /target by the default). Therefore we need to point our Dev mode to this directory. For example, we can use the following properties in the GWT maven plugin:

                  <devmodeWorkDir>${project.build.directory}/classes/static</devmodeWorkDir>
                  <launcherDir>${project.build.directory}/classes/static</launcherDir>
                  <warDir>${project.build.directory}/classes/static</warDir>
  

Full example available at: https://github.com/zak905/boot-gwt