当前位置: 首页 > 知识库问答 >
问题:

R2dbc-postgresql 0.8.0。Spring Boot 2.2中的RC1无法正常工作

范振海
2023-03-14

在我更改了我的Spring webflow(Spring boot2.2.0. m3到2.2.2.2. RELEASE)和r2dbc(spring-data-r2dbc 1.0.0. M2到1.0.0. RELEASE)和r2dbc-postgresql(1.0.0. M7到0.8.0. M8)项目的版本后,我一直收到这个错误

java.lang.IllegalArgumentException: Identifier 'password' is not a valid identifier. Should be of the pattern '\$([\d]+)'.
at io.r2dbc.postgresql.ExtendedQueryPostgresqlStatement.getIndex(ExtendedQueryPostgresqlStatement.java:197) ~[r2dbc-postgresql-0.8.0.RC2.jar:0.8.0.RC2]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s):
|_ checkpoint ⇢ SQL "SELECT * FROM rc_user_account WHERE email = $1 AND  password = $2" [DatabaseClient]

我的pom。xml在这里

<?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.2.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.netax</groupId>
<artifactId>...</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>...</name>
<description>..</description>

<properties>
    <flyway.version>6.1.1</flyway.version>
    <java.version>1.8</java.version>
    <snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
    <jwt.version>0.10.5</jwt.version>
    <spring-restdocs.version>2.0.3.RELEASE</spring-restdocs.version>
    <postgres.driver.version>9.3-1104-jdbc41</postgres.driver.version>
    <!-- test server fields -->
</properties>


<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-releasetrain</artifactId>
            <version>Moore-SR3</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-webflux</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.projectreactor</groupId>
        <artifactId>reactor-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.restdocs</groupId>
        <artifactId>spring-restdocs-mockmvc</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt-api</artifactId>
        <version>${jwt.version}</version>
    </dependency>
    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt-impl</artifactId>
        <version>${jwt.version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt-jackson</artifactId>
        <version>${jwt.version}</version>
        <scope>runtime</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.6</version>
    </dependency>

    <!-- other dependency elements omitted -->

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-r2dbc</artifactId>
        <version>1.0.0.RELEASE</version>
    </dependency>

    <!-- a R2DBC driver -->
    <!--        <dependency>-->
    <!--            <groupId>io.r2dbc</groupId>-->
    <!--            <artifactId>r2dbc-h2</artifactId>-->
    <!--            <version>1.0.0.M6</version>-->
    <!--            <exclusions>-->
    <!--                <exclusion>-->
    <!--                    <groupId>com.h2database</groupId>-->
    <!--                    <artifactId>h2</artifactId>-->
    <!--                </exclusion>-->
    <!--            </exclusions>-->
    <!--        </dependency>-->

    <!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
    <!--        <dependency>-->
    <!--            <groupId>com.h2database</groupId>-->
    <!--            <artifactId>h2</artifactId>-->
    <!--            <version>1.4.197</version>-->
    <!--        </dependency>-->


    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
        <version>${flyway.version}</version>
    </dependency>
    <dependency>
        <groupId>io.r2dbc</groupId>
        <artifactId>r2dbc-postgresql</artifactId>
        <version>0.8.0.RC2</version>
    </dependency>

    <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>google-cloud-vision</artifactId>
        <version>1.74.0</version>
    </dependency>
    <dependency>
        <groupId>com.github.Cloudmersive</groupId>
        <artifactId>Cloudmersive.APIClient.Java</artifactId>
        <version>v2.75</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.mvel/mvel2 -->
    <dependency>
        <groupId>org.mvel</groupId>
        <artifactId>mvel2</artifactId>
        <version>2.4.4.Final</version>
    </dependency>

    <dependency>
        <groupId>org.reflections</groupId>
        <artifactId>reflections</artifactId>
        <version>0.9.11</version>
    </dependency>

    <dependency>
        <groupId>org.jooq</groupId>
        <artifactId>jooq</artifactId>
        <version>3.12.3</version>
    </dependency>
    <dependency>
        <groupId>org.jooq</groupId>
        <artifactId>jooq-meta</artifactId>
        <version>3.12.3</version>
    </dependency>
    <dependency>
        <groupId>org.jooq</groupId>
        <artifactId>jooq-codegen</artifactId>
        <version>3.12.3</version>
    </dependency>

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>${postgres.driver.version}</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/io.projectreactor.kafka/reactor-kafka -->
    <dependency>
        <groupId>io.projectreactor.kafka</groupId>
        <artifactId>reactor-kafka</artifactId>
        <version>1.2.1.RELEASE</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework.kafka/spring-kafka -->
    <dependency>
        <groupId>org.springframework.kafka</groupId>
        <artifactId>spring-kafka</artifactId>
        <version>2.3.4.RELEASE</version>
    </dependency>


</dependencies>

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
    <repository>
        <id>repository.spring.milestone</id>
        <name>Spring Milestone Repository</name>
        <url>http://repo.spring.io/milestone</url>
    </repository>
    <repository>
        <id>central</id>
        <name>Maven Central</name>
        <url>https://repo1.maven.org/maven2</url>
    </repository>

</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <url>https://repo.spring.io/snapshot</url>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <url>https://repo.spring.io/milestone</url>
    </pluginRepository>
</pluginRepositories>

<build>
    <plugins>
        <plugin>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoctor-maven-plugin</artifactId>
            <version>1.5.8</version>
            <executions>
                <execution>
                    <id>generate-docs</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>process-asciidoc</goal>
                    </goals>
                    <configuration>
                        <backend>html</backend>
                        <doctype>book</doctype>
                        <attributes>
                            <snippets>${snippetsDirectory}</snippets>
                        </attributes>
                        <sourceDirectory>src/docs/asciidocs</sourceDirectory>
                        <outputDirectory>target/generated-docs</outputDirectory>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.restdocs</groupId>
                    <artifactId>spring-restdocs-asciidoctor</artifactId>
                    <version>${spring-restdocs.version}</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <profiles>
                    <profile>dev</profile>
                    <profile>test</profile>
                    <profile>qa</profile>
                </profiles>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <executions>
                <!-- Replacing default-compile as it is treated specially by maven -->
                <execution>
                    <id>default-compile</id>
                    <phase>none</phase>
                </execution>
                <!-- Replacing default-testCompile as it is treated specially by maven -->
                <execution>
                    <id>default-testCompile</id>
                    <phase>none</phase>
                </execution>
                <execution>
                    <id>java-compile</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
                <execution>
                    <id>java-test-compile</id>
                    <phase>test-compile</phase>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-maven-plugin</artifactId>
            <version>${flyway.version}</version>
            <dependencies>
                <dependency>
                    <groupId>org.postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                    <version>${postgres.driver.version}</version>
                    <scope>runtime</scope>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

我失败的业务逻辑如下

public Mono<LoggedIn> login(LoginRequest request) {

return Hashing.hashPassword(request.getPassword())
    .flatMap(hashedPassword -> {
      log.info(hashedPassword);
      return userAccountRepository.findByUsernameAndPassword(request.getUsername(), hashedPassword);
    })
    .doOnError(throwable -> log.error(throwable.getMessage(), throwable))
    .doOnNext(userAccountEntity -> log.info("Login attempt : {}", userAccountEntity))
    .switchIfEmpty(Mono.error(ErrorHandlerFactory.newException(ErrorCode.USER_NOT_FOUND_ERROR)))
    .map(userAccount -> {
      String accessToken = util.generateToken(userAccount.getUuid(), Role.USER);
      return LoggedIn.builder()
          .name(userAccount.getFirstName())
          .surname(userAccount.getLastName())
          .profilePictureUrl(Optional.empty())
          .company(Company.builder().name("Netax AS").description("description here").build()) // todo fix here
          .accessToken(accessToken)
          .build(); // todo omitted feature
    });}

你能帮我找出为什么会出现这个错误吗?

共有1个答案

郭炳
2023-03-14

我也犯了同样的错误。我不知道您的存储库是什么样子,但在我的存储库中:

@Query("select id, title from user where title ilike $1")
Flux<User> findAllSpecial(String title); 

错误“java.lang.IllegalArgumentException:标识符“title”不是有效的标识符。应为“\$([\d])”模式。”

@Query("select id, title from user where title ilike :title")
Flux<User> findAllSpecial(String title);

作品。

 类似资料:
  • 问题内容: 我在Java中使用以下使用selenium的代码。我要添加4秒的pageLoadTimeout,但是,驱动程序将继续等待,直到整个页面加载完毕。有什么帮助吗? 问题答案: 解决该 问题的方法是将您的 版本升级到 v3.5.0 。这是有效的代码块,并且使用 最少的代码即可生成您自己的代码: 代码块: 控制台输出: 捕获WebDriverException 代码块: 控制台输出:

  • 问题内容: 尽管我很确定这是昨天或前一天工作的,例如,在IE10中不再起作用。我已经测试了我的浏览器,但是它不再起作用了。还有谁有相同的问题吗?或者,它永远都行不通吗? 问题答案: IE不支持输入type =“ number”,但您可以使用jQueryUISpinner小部件。它非常易于使用,并且具有许多对开发人员友好的API。

  • 问题内容: 因此,我的设置无法按我想要的方式工作。因此,每当我运行该程序时,它就会立即从0变为100。我尝试使用,任务,并尝试了,但没有任何尝试。 这是我的程序: @MadProgrammer这是我尝试做一名摆动工作人员并将每个名称写入文档并更新进度栏的尝试。该程序将达到86%左右并停止运行,永远不会创建完成的文档。该程序将创建一个空白文档。这是我首先创建的SwingWorker对象,这是两种方法

  • 问题内容: 我在JLayeredpane上有两个JPanels。其中一个显示pdf,重叠的一个具有透明背景(我使用过setOpaque(false))。现在,我可以将图形添加到透明面板中,这样看来我实际上是在注释pdf。我想要一个橡皮擦工具来删除这些注释。我尝试使用以下代码 其中path是由多条线构成的形状。现在,不是在先前的图形上绘制 透明线 ,而是绘制 黑线 。我要去哪里错了? 问题答案: 请

  • 问题内容: 这看起来有效,但无法正常工作。我希望菜单悬停时’huh’div不透明。我尝试了淡入/淡出效果,但效果很好,但只有一次很奇怪。 问题答案: 不带点使用:

  • 问题内容: 我正在编辑从tesseract ocr获得的一些电子邮件。 这是我的代码: 但是输出不正确。 输入: 输出: 但是,当我在每次替换后将结果分配给新的String时,它都能正常工作。为什么在同一字符串中连续分配不起作用? 问题答案: 您将在Javadoc中的String.replaceAll()中注意到,第一个参数是正则表达式。 句点()和管道()以及花括号()都有特殊的含义。您需要对它