簡體   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