REST Service with Spring Boot, Spring JDBC and Jersey
For my little IoT project I'm planning to use Spring Boot as runtime environment, Spring JDBC for the database connection and Jersey 2 for the REST implementation.
Why?
- Why Spring Boot?
- Easy deployment
The deployment of the service should be as simple should be as simple as possible. And what is simpler than copying a jar and start the service with 'java -jar <your_app>'.
The alternative would be to install a servlet container like Tomcat or Jetty. - No XML configuration necessary
I don't like xml configuration and with spring boot nearly all configuration happens by configurations and using defaults.
There is just one small application context xml file which is used for the integration tests. - Maven support
There is a maven plug in for Spring Boot with provides targets for running and packaging the service.
You can also use Gradle but this is a small project and I don't want to waste time writing build scripts.
- Easy deployment
- Why Spring JDBC
- Keep it simple
Because I'm planning to migrate the persistence layer to a NoSQL infrastructure, no real schema is used to store the received data. Using JPA would just add some over head which is not necessary right now.
- Keep it simple
- Why Jersey 2
- I prefer using as standard API like JAX-RS instead a vendor specific implementation like Spring REST.
- Spring Boot supports Jersy 2
Implementation
You can find the source code here
To use Spring Boot with Maven you have to use the 'spring-boot-starter-parent' artifact. This artifact provides the necessary versions for the libraries that can be used with spring boot.
There are other starter artifacts that will provide you with all necessary dependencies.