Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 377
lapots Avatar asked Nov 07 '25 03:11

lapots


1 Answers

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.

like image 77
lapots Avatar answered Nov 08 '25 19:11

lapots



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!