1
resposta

Erro ao subir docker compose

ao subir o docker compose no build da aplicação esta dando erro Error: Could not find or load main class org.springframework.boot.loader.lauch.JarLaucher app-1 | Caused by: java.lang.ClassNotFoundException: org.springframework.boot.loader.lauch.JarLaucher

FROM eclipse-temurin:17-jdk-alpine as builder WORKDIR application COPY mvnw . COPY .mvn .mvn COPY pom.xml . COPY src src RUN ./mvnw package -DskipTests ARG JAR_FILE=target/*.jar COPY ${JAR_FILE} application.jar RUN java -Djarmode=layertools -jar application.jar extract

FROM eclipse-temurin:17-jre-alpine WORKDIR application COPY --from=builder application/dependencies/ ./ COPY --from=builder application/spring-boot-loader/ ./ COPY --from=builder application/snapshot-dependencies/ ./ COPY --from=builder application/application/ ./ ENTRYPOINT ["java", "org.springframework.boot.loader.lauch.JarLaucher"]

1 resposta

Oi Erick!

Parece que você está enfrentando um problema com a configuração do seu Dockerfile, especificamente na linha do ENTRYPOINT. O erro indica que a classe org.springframework.boot.loader.lauch.JarLaucher não foi encontrada. Note que há um erro de digitação: JarLaucher deveria ser JarLauncher.

Aqui está a correção no seu Dockerfile:

FROM eclipse-temurin:17-jdk-alpine as builder
WORKDIR application
COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
COPY src src
RUN ./mvnw package -DskipTests
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract

FROM eclipse-temurin:17-jre-alpine
WORKDIR application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]

Note que eu corrigi org.springframework.boot.loader.lauch.JarLaucher para org.springframework.boot.loader.JarLauncher no ENTRYPOINT.

Espero ter ajudado e bons estudos!