繁体   English   中英

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

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

我正在尝试使用Spring BootH2使用反应式存储库。

我添加了依赖项

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'

我的域看起来像这样

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

当依赖是

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

一切正常。 但是由于我添加了r2dbc依赖项,因此无法找到javax.persistence注释的任何依赖项。 当我将starter-jpa与反应式存储库一起使用时,它在启动时失败( Reactive Repositories are not supported by JPA常规Reactive Repositories are not supported by JPA )。

如何解决问题? 手动添加javax.persistence依赖?

问题是什么?

作为解决方案,我决定切换到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;

此外,我必须通过 SQL 脚本手动创建表。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM