I am currently playing around a bit with Spring Boot.
It’s quite a neat project, but I found that having to set up the projects involved a bit of copy and paste from the Spring.io guide pages. Wouldn’t it be great if you had an easier tool to deal with project templating and generation?
As an avid user of the Yeoman generator for my Angular projects, I decided to write a small Spring Boot generator that will include the correct starters and help me scaffold my services. At the end, it ended up being very close to the scaffolding functionality available to other tools like Grails and Play.
Here is a 2 minute video I put together showing the tool in action:
npm install yo spring-generator -g
This will install all the dependencies you need.
Creating an App
Create a new directory and go into it:
mkdir myRestApp && cd $_
Create an app, the wizard will ask you some questions about your project, and you’ll be able to select the starters you want to include for your project.
This will generate a build.gradle file and an application.java file. You can now run your application via
You can also generate intellij idea projects via
gradle idea, and a wrapper via
Scaffolding a REST endpoint
Currently, there is one sub-generator you can call via:
This will take you step by step in generating a representation and a controller that will serve out a REST endpoint. It is based on this guide on Spring.io.
It looks like this in action:
Right now this project is just a toy exploring how to use Yeoman to flesh out Spring Boot. I would like to add a sub-generator for HATEOAS links, Thymeleaf/web scaffolding, war generation, security integration, Maven and basic Spock test scaffolding in due time.
The source is available on https://github.com/tomaslin/generator-spring