# .___ __ _____ __ __ .__
# ______ __| _/_____/ |_ / _ \ __ ___/ |_ ____ _____ _____ _/ |_|__| ____ ____
# / ___// __ |/ __ \ __\/ /_\ \| | \ __\/ _ \ / \\__ \\ __\ |/ _ \ / \
# \___ \/ /_/ \ ___/| | / | \ | /| | ( <_> ) Y Y \/ __ \| | | ( <_> ) | \
# /____ >____ |\___ >__| \____|__ /____/ |__| \____/|__|_| (____ /__| |__|\____/|___| /
# \/ \/ \/ \/ \/ \/ \/
Sample project using Spring Boot 2 and Java
This project is made for anyone who is looking for an example of how to create a rest endpoint using Java Spring Boot & Gradle.
This service calls a local h2 database. Please see resources/data.sql directory for more details.
This project was written using IntelliJ Community Edition.
This project uses gradle build tool.
If you are on MacOS you can install the dependency using homebrew:
brew install gradle
However, this project implements a gradle wrapper, all gradle commands can be executed using the gradle wrapper.
After you have performed all the dependency installations from above, you can run the following command on your terminal to start this app.
From the root of this project enter the following terminal command:
build & test: ./gradlew clean build
running the application locally:
./gradlew bootrun
or
java -jar ./build/libs/users-0.0.1-SNAPSHOT.jar
Or you can also start the application within IntelliJ.
This project uses a local h2 database for a repository.
This project contains a swagger ui.
For more information regarding swagger. Click here.
For more information regarding SpringFox. Click here.
To view this api's swagger ui, run this application locally, then navigate to [http://localhost:8080/swagger-ui.html]
This app is also deployed using heroku. To view deployed api swagger navigate to https://springboot-users-api.herokuapp.com/swagger-ui.html
You can test out this api entirely from the swagger ui page.
GET - getAll - local: /users/v1
GET - getById - local: /users/v1/{userId}
GET - getByUsername - local: /users/v1/byusername/{username}
POST - createUser - local /users/v1 + include a json body with fields
PUT - updateUser - local: /users/v1/{userId} + include a json body with fields.
DELETE - deleteUser - local: /users/v1/{userId}
GET - getAll - local: /users/v1
GET - getById - local: /users/v1/{userId}
GET - getByUsername - local: /users/v1/byusername/{username}
POST - createUser - local /users/v1 + include a json body with fields
PUT - updateUser - local: /users/v1/{userId} + include a json body with fields.
DELETE - deleteUser - local: /users/v1/{userId}
This api is fully tested with Unit Tests and Integration tests. Please see tests directory for examples.
Test's connects to h2 database for integration tests.
This project is a Spring Boot project. For more information click here
This application can be run in Docker. Please see Dockerfile for image setup. Steps to create an image & how to run the app in a container below. (must have docker installed)
Create a docker image: docker build -t users-api .
Run docker container: docker run -it -p 8080:8080 users-api
*** Once app has started, view the swagger ui by navigating to [http://localhost:8080/swagger-ui.html] ***
View docker images: docker images
View docker containers: docker ps -a
Remove docker images: docker rmi $(docker images -q)
Remove docker containers: docker rm $(docker ps -aq)
Click here for more information regarding docker
A web hook has been setup with GitHub Actions for all Push and Pull Requests.
A web hook has been setup with heroku for all deployments.
You can view and try the endpoints here
Please see branches or closed pull requests to see how this project was built step by step.
You can also refer to README_STEPS.MD
Feel free to fork this repo, add to it, and create a pull request if you like to contribute.
If you have any questions, you can contact me via email: [email protected]