Docker Build失败,因为Gradle找不到依赖项

时间:2019-07-28 10:30:04

标签: java docker gradle

我对使用Docker(和Gradle)很陌生,并遇到以下问题。 我可以很好地运行“ bootRun”任务,但是当我运行“ docker build”时,没有任何问题。我得到这个错误。 我可以想象我的gradle设置会导致此问题,而docker恶魔无法加载任何依赖项。

EDIT1:添加了完整的build.gradle。

FAILURE: Build failed with an exception.

* Where:
Build file '/home/gradle/src/build.gradle' line: 17

* What went wrong:
Plugin [id: 'org.springframework.boot', version: '2.1.3.RELEASE'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.boot:org.springframework.boot.gradle.plugin:2.1.3.RELEASE')
  Searched in the following repositories:
    Gradle Central Plugin Repository

这是我的Dockerfile

FROM openjdk:11-slim as builder
COPY . /home/gradle/src
WORKDIR /home/gradle/src
RUN ./gradlew clean generateAll build

FROM openjdk:11-jre-slim
COPY --from=builder /home/gradle/src/build/libs/service*.jar app.jar
EXPOSE 8080
HEALTHCHECK --timeout=3s CMD wget -O - -q localhost:8080/actuator/health
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

这是build.gradle:

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath 'org.openapitools:openapi-generator-documentation:0.1.2'
        classpath 'org.openapitools:openapi-generator-service:0.1.8'
        classpath 'org.openapitools:openapi-generator-client:0.1.9'
    }
}

plugins {
    id 'org.springframework.boot' version '2.1.3.RELEASE'
    id 'java'
    id 'net.linguica.maven-settings' version '0.5'
}

apply plugin: 'io.spring.dependency-management'
apply plugin: 'maven-publish'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {
    compileOnly 'org.projectlombok:lombok:1.18.6'
    annotationProcessor 'org.projectlombok:lombok:1.18.6'
    implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes-all:1.0.1.RELEASE'
    implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes-ribbon:1.0.1.RELEASE'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.postgresql:postgresql'
    compile "org.flywaydb:flyway-core:5.2.4"
    testImplementation group: 'org.mockito', name: 'mockito-core', version: '2.25.1'
}

bootJar {
    launchScript()
}

publishing {
    publications {
        bootJava(MavenPublication) {
            artifact bootJar
        }
    }
}

0 个答案:

没有答案