This is a demo for using JWT (JSON Web Token) with Spring Security and Spring Boot. I completely wrote my first version.
This demo is build with with Maven and Java 8.
Just start the application with the Spring Boot maven plugin (mvn spring-boot:run
). The application is
running at http://localhost:8081.
you can defined more than one user accounts present to demonstrate the different levels of access to the endpoints in the API and the different authorization exceptions like :
- Admin
- Employee
and so on ....
Swagger Documentation
you can access from url: /swagger-ui.html
Generics Exception Handling
Actually this demo is using an mysql database that is manually configured . If you want to connect to another database you have to specify the connection in the application.properties in the resource directory. Here configuration for a MySQL DB:
spring.datasource.url=jdbc:mysql://localhost:3306/t
spring.datasource.username= <your username>
spring.datasource.password= <your password>
# possible values: validate | update | create | create-drop
spring.jpa.hibernate.ddl-auto= update
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL5Dialect
spring.datasource.driver-class-name= com.mysql.jdbc.Driver
You can find a reference of all application properties here.
Emadelddin Juha
Please feel free to send me some feedback or questions!