- maven打包之后,target目录为什么没权限?
如题,mvn package之后,想把war拷贝到tomcat,一直失败。。。 从日志看,打包是成功的: [2021-11-10 18:54:23] [INFO] Packaging webapp [2021-11-10 18:54:23] [INFO] Assembling webapp [nr-engine] in [/nr-engine/target/nr-engine] [2021-11-10 18:54:23] [INFO] Processing war project [2021-11-10 18:54:23] [INFO] Copying webapp webResources [/nr-engine/src/main/webapp] to [/nr-engine/target/nr-engine] [2021-11-10 18:54:23] [INFO] Copying webapp resources [/nr-engine/src/main/webapp] [2021-11-10 18:54:23] [INFO] Building war: /nr-engine/target/nr-engine.war [2021-11-10 18:54:23] [INFO] ------------------------------------------------------------------------ [2021-11-10 18:54:23] [INFO] BUILD SUCCESS [2021-11-10 18:54:23] [INFO] ------------------------------------------------------------------------ [2021-11-10 18:54:23] [INFO] Total time: 01:12 min [2021-11-10 18:54:23] [INFO] Finished at: 2021-11-10T10:54:23Z 但是,拷贝不成功: [2021-11-10 18:54:30] Step 13/15 : COPY ./target/nr-engine.war $CATALINA_HOME/webapps/nr-engine.war [2021-11-10 18:54:30] COPY failed: stat /var/lib/docker/tmp/docker-builder408548833/target/nr-engine.war: no such file or directory script returned exit code 1 把拷贝的源路径改成绝对路径“/nr-engine/target/nr-engine.war”也一样。。。 后来在Dockerfile中加了命令 ls,发现目录确实是存在的; 后来又加命令 ls -l target ,发现没权限!应该是这个原因,才会导致拷贝(ADD 和 COPY 都试过)失败。 有谁碰到过吗?这是什么情况? 以下是Dockerfile: FROM maven:3.8.3-openjdk-8 # 指定Maven环境变量(这里由于使用官方镜像,路径按照官方镜像Dockerfile中的来,否则会找不到mvn) ENV MAVEN_HOME /usr/share/maven ENV PATH $MAVEN_HOME/bin:$PATH WORKDIR /nr-engine COPY ./nr-engine/pom.xml . COPY ./nr-engine/src ./src COPY ./nr-engine/setting.xml ./setting.xml RUN rm -rf target && mkdir -m +r "target" RUN ${MAVEN_HOME}/bin/mvn -U clean package --settings /nr-engine/setting.xml -DskipTests # 添加tomcat容器到镜像中 FROM tomcat:jre8-openjdk # 保险起见,按照tomcat官方镜像配置环境变量 ENV CATALINA_HOME /usr/local/tomcat ENV PATH $CATALINA_HOME/bin:$PATH # 将war包添加进tomcat # # ADD nr-engine.war $CATALINA_HOME/webapps/ COPY ./target/nr-engine.war $CATALINA_HOME/webapps/nr-engine.war # 指定端口 EXPOSE 8080 # CMD ["catalina.sh", "run"] RUN $CATALINA_HOME/bin/catalina.sh 环境参数: 环境id:env-joker-6gp22nkt49926152 服务名称:jz 版本:jz-023 状态:构建失败
2021-11-10 - Maven项目Tomcat发布,如何使用云托管?
如题,码云上的mavn项目想使用云托管部署 如果我在Dockerfile中引用官方mavn镜像,那tomcat该怎么弄呢 是需要再弄个tomcat镜像、还是可以搞到一个镜像里面? 如果可以一个镜像的话,Dockerfile怎么写
2021-11-10 - 云托管新建版本时构建失败,mvn命令无法执行如何解决?
FROM maven:3.8.3-openjdk-8 as builder WORKDIR /myprj COPY ./myprj/pom.xml . COPY ./myprj/src ./src RUN mvn package -DskipTests 上面是Dockerfile,下面是自动构建时的报错: [2021-11-09 18:19:17] Step 5/5 : RUN mvn package -DskipTests [2021-11-09 18:19:17] ---> Running in 30203843a062 [2021-11-09 18:19:17] [91mls: cannot access '/usr/bin/mvn': Operation not permitted [2021-11-09 18:19:17] [0m[91mError: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher [2021-11-09 18:19:17] [0mThe command '/bin/sh -c mvn package -DskipTests' returned a non-zero code: 1 script returned exit code 1
2021-11-10