spark-java - 在 org.gradle.api.internal.artifacts.dsl 类型的对象上找不到参数 [com.sparkjava:spark-core:2.9.3] 的方法 compile()
问题描述
我正在尝试学习 spark java web 框架。我正在使用 Intellij 并创建了一个新项目,刚刚添加了一个 HelloWorld 类,但出现此错误,
Build file '/Users/mingwang/SourceCodes/spark-example/build.gradle' line: 17
A problem occurred evaluating root project 'spark-example'.
> Could not find method compile() for arguments [com.sparkjava:spark-core:2.9.3] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
我的 build.gradle 就像
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '7.0.0'
}
group 'org.example'
version '1.0-SNAPSHOT'
mainClassName = "HelloWorld"
repositories {
mavenCentral()
}
dependencies {
compile "com.sparkjava:spark-core:2.9.3"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
test {
useJUnitPlatform()
}
有人可以帮我吗?谢谢。
解决方案
该compile
语句已弃用,并已在 Gradle 7.0 中删除。您应该使用implementation
orapi
代替。此答案中解释了差异。
在您的 build.gradle 中,替换
compile "com.sparkjava:spark-core:2.9.3"
和
implementation "com.sparkjava:spark-core:2.9.3"
推荐阅读
- c - 减小二进制文件的大小
- configuration - 配置目标域以接受 CNAME
- php - 更新查询未反映到数据库 phpmyadmin
- javascript - 香草javascript中的Ajax jquery POST实现
- numpy - 对大于 2 行的区域的并集进行着色
- php - 使用php和mysql在flutter中发布/获取多个数据到服务器
- javascript - 如何储存新的 div 并在反应中保持以前的价值?
- c++ - 调整窗口大小后出现 OpenGL nvoglv32.dll 错误
- spring - 如何从外部配置中指定的完全限定类名创建 bean?(春天)
- c - 如何重置计时器0?