与 JIB Gradle 集成导致编译错误

Integration with JIB Gradle cause compilation error

尝试将 JIB(容器化您的 Gradle Java 项目)与我的 Java 项目集成。

遵循此文档:https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin

将以下内容添加到我的项目中:

dependencies {
  classpath("gradle.plugin.com.google.cloud.tools:jib-gradle-plugin:3.1.4")
}
apply plugin: 'com.google.cloud.tools.jib'
jib.to.image = 'my-docker-local/my-app'

Gradle版本为:5.6.4

使用“./gradlew”构建的编译工作正常。但当 执行“gradle jib”出现以下错误:

gradle jib To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.2/userguide/gradle_daemon.html#sec:disabling_the_daemon. Daemon will be stopped at the end of the build

FAILURE: Build failed with an exception.

  • Where: Build file '/Users/igorgumush/dev/java11/my-service/build.gradle' line: 139

  • What went wrong: A problem occurred evaluating root project 'my-service'.

Could not find method compile() for arguments [org.springframework.boot:spring-boot-starter-web, build_9nl2gys0kuhc8m4mdlq51u41r$_run_closure4$_closure24@6ea6088b] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

好吧,解决方案非常简单。 我用过:

./gradlew jib

而不是

grade jib