解决分层打包后,报Could not find or load main class org.springframework.boot.loader.JarLauncher错误

解决分层打包后,报Could not find or load main class org.springframework.boot.loader.JarLauncher错误

发现问题

升级到springboot 3.2 后,之前的分层打包启动后会报一下错误

Error: Could not find or load main class org.springframework.boot.loader.JarLauncher
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.loader.JarLauncher

经Google搜索发现之前的org.springframework.boot.loader.JarLauncher已经被弃用, 需要修改对应的配置

Spring-Boot-3.2-Release-Notes#nested-jar-support
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.2-Release-Notes#nested-jar-support

相关问题 Relocate launcher classes to 'org.springframework.boot.loader.launch' package #37667
Error: Could not find or load main class org.springframework.boot.loader.PropertiesLauncher #38775

修改相关配置

  • 修改 docker-entrypoint.sh
    修改前

    修改后

Dockerfile

#
# build jar stage
#
FROM maven:3.9.5-eclipse-temurin-17 AS MAVEN_BUILD

COPY pom.xml /build/
COPY . /build/
WORKDIR /build/
RUN mvn clean package -Dmaven.test.skip=true

#
FROM eclipse-temurin:17-jdk-jammy as builder
WORKDIR application
COPY --from=MAVEN_BUILD /build/target/*.jar application.jar
RUN java -Djarmode=layertools -jar application.jar extract

FROM eclipse-temurin:17-jre-jammy
WORKDIR application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/application/ ./
COPY docker-entrypoint.sh ./
RUN chmod +x docker-entrypoint.sh
ENTRYPOINT ["./docker-entrypoint.sh"]
  • 修改maven打包配置
    修改前

    修改后
posted @ 2023-12-22 15:07  Pursue`  阅读(1311)  评论(0编辑  收藏  举报