A Spring Boot Generator for Yeoman

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.

Video Demo

Here is a 2 minute video I put together showing the tool in action:


Just call 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.

Screen Shot 2013-10-02 at 3.25.13 AM

This will generate a build.gradle file and an application.java file. You can now run your application via gradle run

You can also generate intellij idea projects via gradle idea, and a wrapper via gradle wrapper.

Scaffolding a REST endpoint

Currently, there is one sub-generator you can call via:

yo spring:rest

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:

Screen Shot 2013-10-02 at 3.32.12 AM

What’s Next

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

Yeoman rocks.


3 thoughts on “A Spring Boot Generator for Yeoman

  1. Pingback: Yeoman Generator for Spring Boot update 0.1.1 | Tomás Lin's Programming Brain Dump

  2. Pingback: Forget about Archetypes – Yeoman Generators | Effective Trainings & Consulting

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s