Recipe Web Application using Spring Boot + REST + Spring Data JPA + Spring Security + JQuery Ajax + Bootstrap + Swagger2 + JUnit + Mockito
A single page web application which allows users to manage their favourite recipe with basic CRUD operations using an embedded database H2
- Java 8
- Apache Maven
- Clone project in IDE
- Find
RecipeApplication.java
, select 'Run As' > 'Java Application'. - Point browser to http://localhost:8080/kitchenworld/. If you want to change the context go to
application.properties
and change the value ofserver.servlet.context-path
- You should be redirected to a login page. By default a user with admin rights is created with credentials -> Username :
admin
& Password :password
along with some dummy recipe data using thedata.sql
file - Project uses H2 as the embedded database and a
data base file
with namerecipe-db
is created in the user directory. To change the name of the file go toapplication.properties
and change the value ofspring.datasource.url
. For more info visit http://www.h2database.com/html/faq.html.
Note: Data will not be permanently persisted unless you change the value ofspring.jpa.hibernate.ddl-auto
toupdate
- By default, the H2 console is enabled and it hosted at http://localhost:8080/kitchenworld/h2-console/. This can be changed in
application.properties
by changing the value ofspring.h2.console.enabled
andspring.h2.console.path
- Encryption keys are configured to use external properties file at ${user.home}/recipe-config.properties. You can change the location and name of the file in EncryptionUtil.java.
Access to API Documentation is over http://localhost:8080/kitchenworld/swagger-ui.html and http://localhost:8080/kitchenworld/v2/api-docs
All endpoints are configured to accept Basic Authentication.(For production grade code, Basic Authentication should not be used.) You can change the configuration in MultiHttpSecurityConfig.java
For our dummy admin
use Authorization
header with value Basic YWRtaW46cGFzc3dvcmQ=
.
GET
single recipe : http://localhost:8080/kitchenworld/api/recipes/{id}GET
all recipes : http://localhost:8080/kitchenworld/api/recipes/GET
with limit and offset : http://localhost:8080/kitchenworld/api/recipes?limit={limit}&page={offset}GET
total recipe size : http://localhost:8080/kitchenworld/api/recipes/sizePOST
new recipe : http://localhost:8080/kitchenworld/api/recipesPUT
update recipe : http://localhost:8080/kitchenworld/api/recipes/{id}DELETE
recipe : http://localhost:8080/kitchenworld/api/recipes/{id}