https://grokonez.com/spring-framework/spring-data-rest/spring-boot-react-redux-postgresql-crud-example

在本教程中,我们将构建 React Redux Http Client 和 Spring Boot Server 示例,该示例使用 Spring Data JPAPostgreSQL 数据库交互,并使用 React 作为前端技术来发出请求和收到回复。

相关文章:如何在 PostgreSQL 中使用 Spring JPA |弹簧靴

技术

  • Java 1.8

  • Maven 3.3.9

  • Spring Tool Suite 3.9.0.RELEASE

  • Spring Boot 2.0.1.RELEASE

  • Webpack 4.4.1

  • 反应 16.3.0

  • Redux 3.7.2

  • 反应 Redux 5.0.7

  • axios 0.18.0

  • PostgreSQL 9.5.3

概述

[react-redux-spring-boot-postgresql-crud-example-result-show-books](https://res.cloudinary.com/practicaldev/image/fetch/s--by4CJju2--/c_limit %2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://grokonez.com/wp-content/uploads/2018/05/react-redux-spring-boot-postgresql-crud-example-result-show-books.png)

1.春季启动服务器

[react-redux-spring-boot-postgresql-crud-example-spring-server](https://res.cloudinary.com/practicaldev/image/fetch/s--M1Gosa65--/c_limit%2Cf_auto %2Cfl_progressive%2Cq_auto%2Cw_880/https://grokonez.com/wp-content/uploads/2018/05/react-redux-spring-boot-postgresql-crud-example-spring-server.png)

带有 PostgreSQL 的 Spring Data JPA 示例:

如何将 Spring JPA 与 PostgreSQL 一起使用弹簧靴

2.反应 Redux 客户端

[react-redux-spring-boot-postgresql-crud-example-react-client](https://res.cloudinary.com/practicaldev/image/fetch/s--tBURABie--/c_limit%2Cf_auto %2Cfl_progressive%2Cq_auto%2Cw_880/https://grokonez.com/wp-content/uploads/2018/05/react-redux-spring-boot-postgresql-crud-example-react-client.png)

有关以下内容的更多详细信息:

  • Redux:一个简单实用的 Redux 例子

  • 中间件:中间件与 Redux Thunk

  • 将 React 与 Redux 连接:如何将 React 与 Redux 连接 - react-redux 示例

实践

项目结构

1\。春季启动服务器

[react-redux-spring-boot-postgresql-crud-example-react-spring-server-structure](https://res.cloudinary.com/practicaldev/image/fetch/s--f8LJH_ek-- /c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://grokonez.com/wp-content/uploads/2018/05/react-redux-spring-boot-postgresql-crud-example-react-spring-server-structure .png)

  • Book 对应于 books 集合中的文档。

  • BookRepository 是一个扩展 CrudRepository 的接口,将在 BookController 中自动装配以实现存储库方法和查找器方法。

  • BookController 是一个 REST 控制器,它具有 RESTful 请求的请求映射方法,例如:getAllcreateupdatedeleteBooks。

  • application.propertiesSpring Data JPA 属性的配置。

pom.xml 中的 Spring BootSpring Data JPA 的* 依赖项。

https://grokonez.com/spring-framework/spring-data-rest/spring-boot-react-redux-postgresql-crud-example

Logo

PostgreSQL社区为您提供最前沿的新闻资讯和知识内容

更多推荐