Spring-Boot Example
This is a sample Java / Spring / Maven / MongoDB / application that can be used as a starter.
Security
Authentication based on Json Web Token.
Requirements
- Java Platform (JDK) 8
- MongoDB or by
docker pull mongo
- Apache Maven 3.x
Quick start
- Clone this project
- Run MongoDB process(
docker run --name mongo-latest -v /opt/db/mongo:/data/db -p 27017:27017 -d mongo:latest
). - Run in console
mvn clean install
,java -jar target/*.jar
or justmvn spring-boot:run
- Point your browser to http://localhost:8080/
API urls
- Authentication: POST to
/auth/login
with body(example)
{
"username": "admin",
"password": "admin"
}
-
Secured page: GET to
/secured
with header type:x-auth-token
and token value. -
Load all users: GET to
/api
. -
Load user by ID: GET to
/api/{id}
.