However, getting it going takes a lot of initial effort and there are a few gotchas that need to be taken into account (for example the not-exactly-intuitive behavior of @ComponentScan which caused me to waste a couple of hours chasing shadows).
I have created a “skeleton Spring Boot project” that can be used as a starting point to build a fully-fledged REST-based microservice.
To get going:
git clone email@example.com:massenz/spring-template.git cd spring-template rm -rf .git cd .. mv spring-template my-project cd my-project git init
You can then create a new repo on github and push to that one (just follow the instruction on github.com). Remember to update in the POM the name of the artifact, the groupId, etc.
The pom.xml also includes the necessary dependencies and configuration to enable automatic test coverage (Cobertura); Travis CI and Coveralls.io are also enabled:
# To create test coverage reports (in target/site/cobertura) mvn clean cobertura:cobertura test # To upload to coveralls.io (do NOT push the repo token to github) mvn cobertura:cobertura coveralls:report -DrepoToken=foobazebarerete # To run via maven (Tomcat will be listening on the default # port: localhost:8080) mvn spring-boot:run # To run from the command-line (useful on deployment server who # may not have the JDK/Maven installed): mvn clean package java -jar target/my-project-1.0.SNAPSHOT.jar -Dserver.port=9000
This assumes you have a Mongo server listening on localhost:27017, if that’s not the case, you will have to modify accordingly the MongoDB URI in
For an example of how to integrate with Travis and run automated test, see the configuration file:
For more information, please consult the Spring Boot extensive reference manual.
This project is released under the Apache 2 License.