How to setup Spring Boot RESTful API in 5 minutes
- Use Spring initializr to create a backbone of the project. (https://start.spring.io/)
GroupID: unique identifier of your project. Often reversed company domain name. Ex) sandbox.com → com.sandbox
ArtifactID: name of the jar file without version.
** Add Spring Web on your dependencies. Spring Web provides embedded tomcat by default.
2. Create Controller and POJO.
** It uses Jackson JSON internally. So I don’t have to convert POJO into JSON.
3. Run Spring Boot!
- run application
./gradlew bootRun
- build and run jar file
./gradlew build
java -jar build/libs/pilot-0.0.01-SNAPSHOT.jar
IDE can provide such commands in button form.
Official Documentation is on: https://spring.io/guides/gs/rest-service/
It was nice to NOT configure tomcat, and Jackson JSON conversion, which where two hurdles I have faced coming from Node.js background.