Thursday 2 October 2014

Spring boot

This is a quick post, I came across Sping boot (http://projects.spring.io/spring-boot/) during my travels through the internet. It looks very interesting, create a project using Java/Spring and embed a web container right in your jar file so it's super easy to run.

So I decided to look at it while writing this post, I have never before used Spring boot. I do however have some good experience working with Tomcat and various Spring projects.

So lets get started:


  1. Go to http://start.spring.io/ configure a project and download. I gave mine some sample information and didn't choose any extra libraries, I chose Jar packaging.
  2. You will get a starter.zip file, unpack the file somewhere handy like the desktop.
  3. Inside the starter directory I have a configured pom.xml and some starter Java code.
  4. Install maven and run mvn install, you should see in the output various dependencies being downloaded then a success message.
  5. Run mvn package and it will run the tests and create a jar file in the target directory.
  6. Run java -jar <name of built jar file> and navigate to http://localhost:8080 and a warning message will be displayed.
  7. Update the Application.java file and add an endpoint, run mvn package once more, and navigate to your endpoint (I include my Application.java file below as an image).

You can check out the source code in https://github.com/bark4mark/springBootStarter it is very straight forward.

5 minutes and you have everything configured ready to start work :)

I look forward to writing more on this!


No comments:

Post a Comment