既然添加了依赖项,为什么org.apache.hc
未解析?
package com.blah
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
// Error seen when import line is uncommented:
// 'Unresolved reference: hc'
// import org.apache.hc.client5.http.utils.URLEncodedUtils <--------
import org.w3c.dom.Element
import org.xml.sax.InputSource
import java.io.FileWriter
import java.io.StringReader
import java.net.URI
import java.util.*
val projectVersion: String by project
val liquibaseVersion: String = "4.13.0"
val liquibaseGradlePluginVersion: String = "2.0.4"
plugins {
java
id("org.springframework.boot") apply false
id("org.liquibase.gradle") apply true
}
dependencies {
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
liquibaseRuntime(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
implementation("org.postgresql:postgresql")
implementation("org.liquibase:liquibase-core:$liquibaseVersion")
implementation("org.liquibase:liquibase-gradle-plugin:$liquibaseGradlePluginVersion")
implementation("org.hibernate:hibernate-core")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("com.fasterxml.jackson.core:jackson-core")
implementation("com.fasterxml.jackson.core:jackson-databind")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
// No errors when building the Gradle model during import into IDE
// https://mvnrepository.com/artifact/org.apache.httpcomponents.core5/httpcore5
implementation("org.apache.httpcomponents.core5:httpcore5:5.2.1")
liquibaseRuntime("org.liquibase:liquibase-core:$liquibaseVersion")
liquibaseRuntime("org.postgresql:postgresql")
liquibaseRuntime("org.springframework.boot:spring-boot-starter-data-jpa")
liquibaseRuntime(sourceSets.getByName("main").output)
}
1条答案
按热度按时间yzuktlbb1#
在
dependencies {}
块中声明的依赖项被添加到项目的类路径中,而不是构建脚本的类路径中。如果要在Gradle构建脚本中使用依赖关系,则有两个选项
1.在
build.gradle(.kts)
中使用buildscript {}
块1.在included build或buildSrc中定义依赖项