【问题标题】:Cannot resolve method 'execute' in 'DatabaseClient'无法解析“数据库客户端”中的方法“执行”
【发布时间】:2021-04-14 05:33:43
【问题描述】:

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

  1. 无法解析“DatabaseClient”中的“execute”方法
  2. 对“create”的引用不明确,“create(Publisher extends T>)”和“create(Publisher extends T>, long)”都匹配

代码

  @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());

    }

【问题讨论】:

  • 使用文章中提到的确切库版本。 API 可以更改。

标签: java spring spring-data spring-data-r2dbc r2dbc


【解决方案1】:

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

所以要么你应该使用 .sql() 而不是 .execute() 或者只是降级 Spring/R2DBC 版本

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-16
    • 2017-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-05
    相关资源
    最近更新 更多