I wanted to explore an approach which Spring framework recommends for handling static web resources, which is to use these very capable build tools for building the static assets and using Spring for serving out the content once the static assets are built into a distributable state.
My approach was to use yeoman to generate a starter project, I chose the gulp-angular as my base and quickly generated a complete project, available here. I was able to expand this template into a fairly comprehensive angularjs based single page application which delegates back to Spring based REST calls to service the UI.
If you want to follow along the end result is available in my github repo.
- Define two modules, the “client” module to hold the generated yeoman template and a “server” module to hold the Spring Boot application.
- Hack away on the “client” module, in this specific instance I have created a simple angularjs based application
- In the “server” module client is added as a dependency and “server” is set to be run as a full-fledged spring-boot project
- Serve out the project from the server module by executing:
|Reference:||Spring boot static web resource handling for Single Page Applications from our JCG partner Biju Kunjummen at the all and sundry blog.|