简体   繁体   English

导入 io.r2dbc.postgresql.codec 时 gradle 出现问题

[英]Problem with gradle when importing io.r2dbc.postgresql.codec

Every time i try to build or run from gradle (gradle bootRun or./gradlew bootRun), while importing io.r2dbc.postgresql.codec.Json, i get this error: Every time i try to build or run from gradle (gradle bootRun or./gradlew bootRun), while importing io.r2dbc.postgresql.codec.Json, i get this error:

Stack trace 堆栈跟踪
package com.test.backend;

import io.r2dbc.postgresql.codec.Json;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class BackendApplication {
    public static void main(String[] args) {
        SpringApplication.run(BackendApplication.class, args);
        Json test = Json.of("testing");
        System.out.println(test);
    }
}

Steps to reproduce重现步骤

plugins {
    id 'org.springframework.boot' version '2.6.7'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group = 'com.test'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '18'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
    implementation 'org.springframework.boot:spring-boot-starter-data-r2dbc'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'
    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'io.r2dbc:r2dbc-postgresql'
    runtimeOnly 'org.postgresql:postgresql'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'io.projectreactor:reactor-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

build.gradle: build.gradle:

 plugins { id 'org.springframework.boot' version '2.6.7' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' } group = 'com.test' version = '0.0.1-SNAPSHOT' sourceCompatibility = '18' configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jdbc' implementation 'org.springframework.boot:spring-boot-starter-data-r2dbc' implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.boot:spring-boot-starter-webflux' compileOnly 'org.projectlombok:lombok' runtimeOnly 'io.r2dbc:r2dbc-postgresql' runtimeOnly 'org.postgresql:postgresql' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'io.projectreactor:reactor-test' } tasks.named('test') { useJUnitPlatform() }

Expected behavior/code预期行为/代码

When i debug-run the project from the IDE (vscode) it works and prints the Json object.当我从 IDE(vscode)调试运行项目时,它可以工作并打印 Json object。

Versions版本

  • Driver: 0.8.12驱动程序:0.8.12
  • Database: 14.2数据库:14.2
  • Java: 18 Java:18
  • OS: Linux 5.10操作系统:Linux 5.10
  • Gradle: 7.4.2 Gradle:7.4.2

I solved it by changing the build.gradle to:我通过将 build.gradle 更改为:

implementation 'io.r2dbc:r2dbc-postgresql'

It must be versioning problems, I tried this and it is solved:一定是版本问题,我试过了,解决了:

implementation 'org.postgresql:r2dbc-postgresql'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM