maven 为什么我找不到jar文件?

nzkunb0c  于 2023-10-17  发布在  Maven
关注(0)|答案(1)|浏览(154)

我创建了如下示例Java Sping Boot 代码。编码https://github.com/hardreggaecafe/java_spring_boot_sample
当我将这段代码部署到Render.com时,它失败了。Dockerfile在这里。

Dockerfile

FROM maven:3-eclipse-temurin-17 AS build
COPY . .
RUN mvn clean package -Pprod -DskipTests
FROM eclipse-temurin:17-alpine
COPY --from=build /target/QuickMaster-1.0.0.jar demo.jar
EXPOSE 8080
ENTRYPOINT [“java”,“-jar”,“demo.jar”]

错误

Downloaded from central: https://repo.maven.apache.org/maven2/com/google/guava/guava/28.2-android/guava-28.2-android.jar (2.6 MB at 5.8 MB/s)
Aug 15 05:44:08 PM  #11 20.12 [INFO] Replacing main artifact /target/QuickMaster-1.0.0.jar with repackaged archive, adding nested dependencies in BOOT-INF/.
Aug 15 05:44:08 PM  #11 20.12 [INFO] The original artifact has been renamed to /target/QuickMaster-1.0.0.jar.original
Aug 15 05:44:08 PM  #11 20.12 [INFO] ------------------------------------------------------------------------
Aug 15 05:44:08 PM  #11 20.12 [INFO] BUILD SUCCESS
Aug 15 05:44:08 PM  #11 20.12 [INFO] ------------------------------------------------------------------------
Aug 15 05:44:08 PM  #11 20.12 [INFO] Total time:  17.180 s
Aug 15 05:44:08 PM  #11 20.12 [INFO] Finished at: 2023-08-15T08:44:07Z
Aug 15 05:44:08 PM  #11 20.12 [INFO] ------------------------------------------------------------------------
Aug 15 05:44:08 PM  #11 20.12 [WARNING] The requested profile "prod" could not be activated because it does not exist.
Aug 15 05:44:08 PM  #11 DONE 20.3s
Aug 15 05:44:08 PM  
Aug 15 05:44:08 PM  #12 [stage-1 2/2] COPY --from=build /target/QuickMaster-1.0.0.jar demo.jar
Aug 15 05:44:08 PM  #12 DONE 0.1s
Aug 15 05:44:08 PM  
Aug 15 05:44:08 PM  #13 exporting to docker image format
Aug 15 05:44:08 PM  #13 exporting layers
Aug 15 05:44:09 PM  #13 exporting layers 1.1s done
Aug 15 05:44:09 PM  #13 exporting manifest sha256:1ed8ee65532237425105db1aae4daf717d2a9a7713ff828eaceb10c126220ee9 done
Aug 15 05:44:09 PM  #13 exporting config sha256:13704bb38ca3dfc2f382ecf143bcf3adccbd4609b81037ceb10138f1197599f6 done
Aug 15 05:44:14 PM  #13 DONE 6.2s
Aug 15 05:44:14 PM  
Aug 15 05:44:14 PM  #14 exporting content cache
Aug 15 05:44:14 PM  #14 preparing build cache for export
Aug 15 05:44:30 PM  #14 DONE 16.4s
Aug 15 05:44:31 PM  Pushing image to registry...
Aug 15 05:44:34 PM  Upload succeeded
Aug 15 05:44:34 PM  DONE
Aug 15 05:44:51 PM  /bin/sh: [“java”,“-jar”,“demo.jar”]: not found
Aug 15 05:44:52 PM  /bin/sh: [“java”,“-jar”,“demo.jar”]: not found
Aug 15 05:45:08 PM  /bin/sh: [“java”,“-jar”,“demo.jar”]: not found

我不知道/bin/sh: [“java”,“-jar”,“demo.jar”]: not found
如果有人能告诉我怎么修我会很感激的。

wz1wpwve

wz1wpwve1#

您遇到的错误似乎与您在Dockerfile中指定ENTRYPOINT命令的方式有关。这个问题可能源于使用了花引号而不是常规的双引号。Docker要求使用常规双引号来指定命令。
这是导致问题的原始Dockerfile行:

ENTRYPOINT [“java”,“-jar”,“demo.jar”]

用常规双引号替换花引号:

ENTRYPOINT ["java", "-jar", "demo.jar"]

相关问题