对于最新的稳定版本,请使用 Spring Integration 6.5.1spring-doc.cadn.net.cn

JPA 支持

Spring Integration 的 JPA(Java Persistence API)模块提供了使用 JPA 执行各种数据库作的组件。spring-doc.cadn.net.cn

您需要将此依赖项包含在您的项目中:spring-doc.cadn.net.cn

<dependency>
    <groupId>org.springframework.integration</groupId>
    <artifactId>spring-integration-jpa</artifactId>
    <version>6.3.11</version>
</dependency>
compile "org.springframework.integration:spring-integration-jpa:6.3.11"

JPA API 必须通过一些特定于提供商的实现(例如 Hibernate ORM 框架)包含在内。spring-doc.cadn.net.cn

提供以下组件:spring-doc.cadn.net.cn

这些组件可用于执行select,create,updatedelete通过向目标数据库发送和接收消息来对目标数据库进行作。spring-doc.cadn.net.cn

JPA 入站通道适配器允许您轮询和检索 (select) 使用 JPA 从数据库中获取数据,而 JPA 出站通道适配器允许您创建、更新和删除实体。spring-doc.cadn.net.cn

您可以使用 JPA 的出站网关将实体持久化到数据库,从而允许您继续流并在下游执行更多组件。 同样,可以使用出站网关从数据库中检索实体。spring-doc.cadn.net.cn

例如,您可以使用出站网关,该网关接收Message使用userId作为其请求通道上的有效负载,以查询数据库,检索用户实体,并将其传递到下游以进行进一步处理。spring-doc.cadn.net.cn

认识到这些语义差异,Spring Integration 提供了两个独立的 JPA 出站网关:spring-doc.cadn.net.cn