无法解析'DatabaseClient'中的方法'execute'



我尝试重复课程中的代码。SQL查询应该创建用于初始化,并在public void setup((中运行,但我遇到了一些问题:

  1. 无法解析"DatabaseClient"中的方法"execute">
  2. 对"create"的引用不明确,"create(Publisher<?extends T>("one_answers"create

代码

@BeforeAll
public void setup() {
Hooks.onOperatorDebug();
List<String> statements = Arrays.asList(//
"DROP TABLE IF EXISTS player;",
"CREATE table player (id INT AUTO_INCREMENT NOT NULL, name VARCHAR2, age INT NOT NULL);");
statements.forEach(it -> client.execute(it) //
.fetch() //
.rowsUpdated() //
.as(StepVerifier::create) //
.expectNextCount(1) //
.verifyComplete());
}

我猜您使用的是最新的Spring版本,其中某些R2DBC类已被弃用。请在此处查看https://docs.spring.io/spring-data/r2dbc/docs/current/reference/html/#upgrading.1.1-1.2.折旧

因此,您应该使用.sql()而不是.execute(),或者只降级Spring/R2DBC版本

最新更新