Linux环境下通过git和maven下载和打包的操作笔记

准备条件:

Git地址:
git clone https://gitee.com/zxdaima/zx-app-web.git

目录:
/opt/data/pub/zx-app-web/

第一步:git clone

由于我是公开的源码,不需要账号密码

所以效果如下:

Linux环境下通过git和maven下载和打包的操作笔记

通过

mvn clean package -Dmaven.test.skip=true

打包

Linux环境下通过git和maven下载和打包的操作笔记

首次打包会加载许多jar

最后报错:

Linux环境下通过git和maven下载和打包的操作笔记

多次尝试都报错

报错内容

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:3.2.0:clean (default-clean) on project zx-parent: The plugin org.apache.maven.plugins:maven-clean-plugin:3.2.0 requires Maven version 3.2.5 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginIncompatibleException

AI咨询了解到,是版本过低的问题

Linux环境下通过git和maven下载和打包的操作笔记

[root@192 zx-app-web]# mvn -v
Apache Maven 3.0.5 (Red Hat 3.0.5-17)
Maven home: /usr/share/maven
Java version: 1.8.0_311, vendor: Oracle Corporation
Java home: /opt/bin/java/jdk1.8.0_311/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1062.el7.x86_64", arch: "amd64", family: "unix"

需要升级maven,怎么升级?

我先试一下,降低pom.xml里面maven的版本看看

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-clean-plugin</artifactId>
      <version>2.5</version> <!-- 适配 Maven 3.0+ -->
    </plugin>
  </plugins>
</build>

然后

git pull origin dev

Linux环境下通过git和maven下载和打包的操作笔记

继续报错:

[INFO] Reactor Summary:
[INFO]
[INFO] zx-parent ......................................... SUCCESS [10.604s]
[INFO] zx-ba-common ...................................... FAILURE [7.513s]
[INFO] zx-app-web ........................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.771s
[INFO] Finished at: Tue Oct 07 21:57:11 PDT 2025
[INFO] Final Memory: 11M/58M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project zx-ba-common: The plugin org.apache.maven.plugins:maven-resources-plugin:3.2.0 requires Maven version 3.1.0 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginIncompatibleException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :zx-ba-common

还是不行,需要手工升级maven了

升级maven的操作笔记见下面文章:

CentOS升级maven的操作笔记

升级完后,在mvn打包,成功

Linux环境下通过git和maven下载和打包的操作笔记

这个笔记是次要的,后面我要做的是通过脚本自动化发布

打包完后,怎么发布到指定的目录?

见下文

© 版权声明
THE END
如果内容对您有所帮助,就支持一下吧!
点赞0 分享
尘封的头像 - 鹿快
评论 抢沙发

请登录后发表评论

    暂无评论内容