首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >导入io.r2dbc.postgresql.codec时gradle的问题

导入io.r2dbc.postgresql.codec时gradle的问题
EN

Stack Overflow用户
提问于 2022-05-16 16:07:12
回答 2查看 649关注 0票数 0

每次尝试从gradle构建或运行(gradle bootRun或./gradlew bootRun)时,在导入io.r2dbc.postgresql.codec.Json时,都会得到以下错误:

堆栈跟踪

代码语言:javascript
复制
> Task :compileJava FAILED
/home/repos/test-backend/src/main/java/com/dnt/backend/BackendApplication.java:3: error: package io.r2dbc.postgresql.codec does not exist
import io.r2dbc.postgresql.codec.Json;
                                ^
1 error

复制步骤

代码语言:javascript
复制
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);
    }
}

build.gradle:

代码语言:javascript
复制
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()
}

预期行为/代码

当我调试-从IDE (vscode)运行项目时,它工作并打印Json对象。

版本

0.8.12

  • Database: 14.2

  • Java: 18

  • OS: Linux5.10

  • Gradle:7.4.2

F 214

EN

回答 2

Stack Overflow用户

发布于 2022-05-16 16:46:49

我通过将build.gradle更改为:

代码语言:javascript
复制
implementation 'io.r2dbc:r2dbc-postgresql'
票数 1
EN

Stack Overflow用户

发布于 2022-08-18 15:01:39

这一定是版本控制问题,我尝试过了,并且解决了:

代码语言:javascript
复制
implementation 'org.postgresql:r2dbc-postgresql'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72262246

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档