这可能是一个重复的问题,但我已经搜索了很多,我找不到一个答案,工作。我确信我犯了一个简单的错误,但我就是想不出来。
我使用Gradle wrapper 7.6
创建了一个简单的核心Java项目。
我可以使用docker build
命令创建一个docker镜像,但当我运行该命令时,我得到了以下错误:
Could not find or load main class io.confluent.developer.ParallelConsumerApplication
下面是dockerfile
:
FROM gradle:7.6.1-jdk8 AS builder
WORKDIR /app
COPY build.gradle ./
RUN gradle build --scan --stacktrace
FROM adoptopenjdk/openjdk8:alpine-jre
WORKDIR /app
COPY --from=builder /app/build/libs/*.jar .
ENTRYPOINT ["java", "-jar", "app-0.0.1-plain.jar"]
下面是build.gradle
文件:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.github.jengelman.gradle.plugins:shadow:6.1.0"
}
}
plugins {
id "maven-publish"
id "java"
id 'org.springframework.boot' version '2.7.1'
}
//sourceCompatibility = JavaVersion.VERSION_17
//targetCompatibility = JavaVersion.VERSION_17
version = "0.0.1"
repositories {
mavenCentral()
maven {
url "https://packages.confluent.io/maven"
}
}
apply plugin: "com.github.johnrengelman.shadow"
//apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
dependencies {
implementation "io.confluent.parallelconsumer:parallel-consumer-core:0.5.2.4"
implementation "org.apache.avro:avro:1.11.1"
implementation "io.confluent:kafka-avro-serializer:3.3.0"
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.codehaus.jackson:jackson-core-asl:1.9.13"
implementation "org.codehaus.jackson:jackson-mapper-asl:1.9.13"
implementation "org.apache.commons:commons-lang3:3.12.0"
implementation "org.slf4j:slf4j-simple:2.0.0"
implementation "me.tongfei:progressbar:0.9.3"
implementation 'org.awaitility:awaitility:4.2.0'
implementation("log4j:log4j:1.2.17")
testImplementation "junit:junit:4.13.2"
testImplementation 'org.awaitility:awaitility:4.2.0'
testImplementation "io.confluent.parallelconsumer:parallel-consumer-core:0.5.2.4:tests" // for LongPollingMockConsumer
}
test {
testLogging {
outputs.upToDateWhen { false }
showStandardStreams = true
exceptionFormat = "full"
}
}
bootJar {
enabled = false
}
jar {
manifest {
attributes(
"Class-Path": configurations.compileClasspath.collect { it.getName() }.join(" "),
'Main-Class': 'io.confluent.developer.ParallelConsumerApplication',
)
}
}
shadowJar {
archiveBaseName = "confluent-parallel-consumer-application-standalone"
}
这不是一个spring Boot 应用程序,我只是在项目中使用RestTemplate
进行API调用。
任何帮助都很感激。先谢谢你了。
1条答案
按热度按时间k2arahey1#
ParallelConsumerApplication不是任何依赖项提供的东西,它是您自己需要编写的类,请参阅https://developer.confluent.io/tutorials/confluent-parallel-consumer/confluent.html
所以很明显,这个错误是因为你没有在你的应用程序中创建这样一个类。如果使用其他名称创建它,则需要使用主应用程序类的名称,而不是io.confluent.developer.ParallelConsumerApplication