gradle-docker-plugin和SpringBootVersion 2.0.0.M4有一个issue
M4使用较新的jersey客户端,并且使用docker-plugin结束时出现异常:

ERROR com.github.dockerjava.core.async.ResultCallbackTemplate - Error during callback
java.lang.IllegalStateException: InjectionManagerFactory not found.
    at org.glassfish.jersey.internal.inject.Injections.lambda$lookupInjectionManagerFactory$0(Injections.java:98)
    at java.util.Optional.orElseThrow(Optional.java:290)
    at org.glassfish.jersey.internal.inject.Injections.lookupInjectionManagerFactory(Injections.java:98)
    at org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:68)
    at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:432)
    at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:341)
    at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:826)
    at org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:285)
    at org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:143)
    at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:112)
    at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:108)
    at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:99)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:456)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:357)
    at com.github.dockerjava.jaxrs.async.POSTCallbackNotifier.response(POSTCallbackNotifier.java:29)
    at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:50)
    at com.github.dockerjava.jaxrs.async.AbstractCallbackNotifier.call(AbstractCallbackNotifier.java:24)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

我的主项目中的BuildScript:
buildscript {
    ext {
        springBootVersion = "2.0.0.M4"
    }

    repositories {
        maven { url "https://repo.spring.io/plugins-snapshot" }
        maven { url "https://plugins.gradle.org/m2/" }
    }

    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
    }
}
....

如您所见,我们加载了spring-boot-gradle-plugin version = 2.0.0.M4及其所有依赖项。

我的子项目build.gradle:
apply plugin: "org.springframework.boot"
apply from: "docker.gradle"
....

最重要的docker.gradle文件与子项目的build.gradle位于同一目录中:
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.bmuschko:gradle-docker-plugin:3.0.11'
    }
}

apply plugin: com.bmuschko.gradle.docker.DockerRemoteApiPlugin

import com.bmuschko.gradle.docker.tasks.image.*
...
task buildImage(type: DockerBuildImage, dependsOn: copyDockerFiles) {
    version.release = true
    dockerFile = file("${projectDir}/build/docker/Dockerfile")
    inputDir = file("${projectDir}/build/docker")
    tags = ['...']
}

我的问题:
我怎么知道哪个版本的 Jersey 客户端加载SpringBoot 2.0.0.M4?
如何在docker.gradle中强制gradle使用特定版本的jersey客户端?
添加到类路径没有用。我认为gradle只会使用最新版本,而这将由SpringBoot 2.0.0.M4加载

最佳答案

您必须按照以下指示在build.gradle依赖项中添加以下内容:This Link

dockerJava 'com.nirima:docker-java-shaded:0.16.2'
dockerJava 'org.slf4j:slf4j-simple:1.7.5'
dockerJava 'cglib:cglib:3.2.0'

之后,您必须按照This link中的建议分离“buildImage”和“tagImage”任务

我用以下方法测试了此:spring boot 2.0.0.M6

10-08 06:01
查看更多