简体   繁体   中英

cannot find javax.persistence annotations when using spring r2dbc

I am trying to use reactive repositories with H2 using Spring Boot .

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. When I use starter-jpa with reactive repositories it fails on startup (regular Reactive Repositories are not supported by JPA ).

How to solve the problem? Add javax.persistence dependency manually?

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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