简体   繁体   English

使用 spring r2dbc 时找不到 javax.persistence 注释

[英]cannot find javax.persistence annotations when using spring r2dbc

I am trying to use reactive repositories with H2 using Spring Boot .我正在尝试使用Spring BootH2使用反应式存储库。

I have added dependencies我添加了依赖项

implementation 'org.springframework.boot.experimental:spring-boot-starter-data-r2dbc:0.1.0.M1'
implementation 'org.springframework.boot.experimental:spring-boot-actuator-autoconfigure-r2dbc:0.1.0.M1'
implementation 'io.r2dbc:r2dbc-pool:0.8.0.RELEASE'

My domains looked like this我的域看起来像这样

@Entity
@Table(name = "json_comparison")
public class JsonComparisonResult {
    @Column(name = "comparison_id")
    @Id
    private String comparisonId;
    @Column(name = "left")
    private String leftSide;
    ....

When the dependency was to当依赖是

implementation "org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion"

Everything worked fine.一切正常。 But since I have added r2dbc dependencies it wasn't able to find any dependencies for javax.persistence annotations.但是由于我添加了r2dbc依赖项,因此无法找到javax.persistence注释的任何依赖项。 When I use starter-jpa with reactive repositories it fails on startup (regular Reactive Repositories are not supported by JPA ).当我将starter-jpa与反应式存储库一起使用时,它在启动时失败( Reactive Repositories are not supported by JPA常规Reactive Repositories are not supported by JPA )。

How to solve the problem?如何解决问题? Add javax.persistence dependency manually?手动添加javax.persistence依赖?

What is the problem?问题是什么?

As a solution, I decided to switch to org.springframework.data.relational.core.mapping annotations like @Table , @Column and org.springframework.data.annotation @Id .作为解决方案,我决定切换到org.springframework.data.relational.core.mapping注释,如@Table@Columnorg.springframework.data.annotation @Id

import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;

In addition, I had to create tables manually via SQL scripts.此外,我必须通过 SQL 脚本手动创建表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 javax.persistence注释和继承 - javax.persistence annotations and inheritance javax.persistence批注缺少可选元素? - javax.persistence annotations missing optional elements? javax.persistence对field,getter或setter的注释? - javax.persistence Annotations on field, getter or setter? 将 Spring Boot 应用程序(使用 javax.persistence)升级到 JDK 11 - Upgrade Spring Boot app (using javax.persistence) to JDK 11 Spring Autowire 在通用类中找不到 R2DBC 存储库的实现 - Spring Autowire cannot find implementation for R2DBC Repository in Generic Class 使用 Spring 数据 R2DBC 查找/修改/保存或更新插入 - Find/Modify/Save or Upsert with Spring Data R2DBC javax.persistence 不包含在 spring 数据 jpa 中? - javax.persistence not included in spring data jpa? 使用 Spring Data R2DBC 进行批量插入时检索生成的 ID - Retrieve generated IDs when doing bulk insert using Spring Data R2DBC 使用 spring R2DBC 连接 mySQL 服务器版本 8 时出现未知的系统变量“tx_isolation” - Unknown system variable 'tx_isolation' when using spring R2DBC to connect with a mySQL server version 8 使用 Spring Data R2DBC 获取嵌套对象 - Obtaining a nested objects using Spring Data R2DBC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM