tisdag 28 oktober 2014

Spring boot - no more boilerplate

So, just loving the spring boot project. Spring has always been a nice framework but the constant xml hammering for the contexts have been clashing with my hatred of excessive configuration. Along came the spring annotations that made things much more user friendly but still is kind of boilerplate intensive when you just want to go go go. Enter the spring boot project.

Just add the spring boot parent to your artifact.


Boom. You now have all the boilerplate preconfigured by default in your project. Add a spring boot dependency and add a main method to start up the context and Bob (or Bub if you prefer) is your uncle. All you need is the enabling annotation and a main runnable class.


and your class 

public class Application {

    public static void main(String[] args) throws Exception {

        SpringApplication.run(Application.class, args);



I double-dare you to not like this. Just try the spring security dependency. Works by scanning your classpath for key dependency classes and including predefined boilerplate. Just add the deps and boot will kick the config. When you get around to write your own configuration just exclude the boilerplate in the enable auto conf annotation. Like a glove. Or a unicorn. Or a funny cat.