In this tutorial, we will learn how to build a full stack React Redux + Spring Boot example with a CRUD App. The back-end server uses Spring Boot with Spring Web MVC for REST APIs and Spring Data JPA for interacting with embedded database (H2 database). Front-end side is made with React, Redux, React Router, Axios & Bootstrap.
Full Article: https://bezkoder.com/spring-boot-react-redux-example/
The images below shows screenshots of our System.
On this Page, you can:
You can also find the Spring Restful Apis that works with other databases here:
- Spring JPA + PostgreSQL
- Spring JPA + MySQL
- Spring Data + MongoDB
Methods | Urls | Actions |
---|---|---|
POST | /api/tutorials | create new Tutorial |
GET | /api/tutorials | retrieve all Tutorials |
GET | /api/tutorials/:id | retrieve a Tutorial by :id |
PUT | /api/tutorials/:id | update a Tutorial by :id |
DELETE | /api/tutorials/:id | delete a Tutorial by :id |
DELETE | /api/tutorials | delete all Tutorials |
GET | /api/tutorials?title=[keyword] | find all Tutorials which title contains keyword |
JpaRepository
.
- The database will be H2 Database (in memory or on disk) by configuring project dependency & datasource.
– Tutorial
data model class corresponds to entity and table tutorials.
– TutorialRepository
is an interface that extends JpaRepository for CRUD methods and custom finder methods. It will be autowired in TutorialController
.
– TutorialController
is a RestController which has request mapping methods for RESTful requests such as: getAllTutorials, createTutorial, updateTutorial, deleteTutorial, findByPublished…
– Configuration for Spring Datasource, JPA & Hibernate in application.properties.
– pom.xml contains dependencies for Spring Boot and H2 Database.
– The App
component is a container with React Router
. It has navbar
that links to routes paths.
– Three components that dispatch actions to Redux Thunk Middleware
which uses TutorialDataService
to call Rest API.
TutorialsList
component gets and displays Tutorials.Tutorial
component has form for editing Tutorial's details based on :id
.AddTutorial
component has form for submission new Tutorial.– TutorialDataService
uses axios
to make HTTP requests and receive responses.
This diagram shows how Redux elements work in our React Application:
We’re gonna create Redux store
for storing tutorials
data. Other React Components will work with the Store via dispatching an action
.
The reducer
will take the action and return new state
.
react
, react-router-dom
, react-redux
, redux
, redux-thunk
, axios
& bootstrap
.App
is the container that has Router
& navbar.TutorialsList
, Tutorial
, AddTutorial
.TutorialDataService
has methods for sending HTTP requests to the Apis.About Redux elements that we’re gonna use:
For more steps and Source code, please visit:
https://bezkoder.com/spring-boot-react-redux-example/
Related Posts:
Run both projects in one place:
How to integrate React.js with Spring Boot
#spring-framework #react #web-development #spring-boot #spring #redux