After upgrading my spring-boot application from spring-boot version 2.3.9 to 2.5.12
We have started getting below exception. Not sure if there is change related to docker in spring boot version 2.5.12
With previous version it was working fine but after changing gradle to 6.8 and spring-boot version this issue started … any workaround to fix this issue?
This is the command that causes error in Dockerfile
ENV APP_HOME=/app/z-api/
COPY --from=build "${APP_HOME}build/libs/z-api-*.jar" app.jar
COPY –from=build "${APP_HOME}build/libs/z-api-*.jar" app.jar
When using COPY with more than one source file, the destination must be a directory and end with a /
2
Answers
There are now two jars in
build/libs
that matchz-api-*.jar
. This is due to Spring Boot 2.5 no longer disabling thejar
task by default. From the release notes:You could update your
COPY
command so that it doesn’t match the-plain.jar
that’s now produced by thejar
task. Alternatively, you could disable thejar
task:As @andy-wilkinson explained, the reason is that 2 jar files are generated by Gradle as
If you prefer that the plain archive isn’t built at all, disable its task.
If you are using Kotlin with Gradle, add the following script to
build.gradle.kts
Read more on https://docs.spring.io/spring-boot/docs/2.5.x/gradle-plugin/reference/htmlsingle/#packaging-executable.and-plain-archives