[英]cannot find javax.persistence annotations when using spring r2dbc
I am trying to use reactive repositories with H2
using Spring Boot
.我正在尝试使用Spring Boot
在H2
使用反应式存储库。
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
、 @Column
和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.此外,我必须通过 SQL 脚本手动创建表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.