处理Jenkins使用Maven自动构建jar文件过慢问题【以docker下部署为例】

艺帆风顺 发布于 2025-04-03 18 次阅读


一、问题背景

    使用Jenkins构建jar包速度太慢,耗时太久。

二、问题处理

    1、进入容器

docker exec -it bfd929c0d3d5  /bin/bash

     2、切换到maven的配置目录、修改配置文件

    cd /usr/local/maven/conf/vim settings.xml  #配置文件内容如下:

    "http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"> alimaven aliyun central http://maven.aliyun.com/nexus/content/groups/public org.apache.maven.plugins org.codehaus.mojo

    3、验证

        重新构建,可以发现已经切换到阿里的maven仓库了,速度明显提升。

      [INFO] from base-boot/pom.xml[INFO] --------------------------------[ jar ]---------------------------------[INFO] Downloading from jcenter-releases: http://jcenter.bintray.com/org/apache/tomcat/embed/tomcat-embed-core/8.5.31/tomcat-embed-core-8.5.31.pom[INFO] Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/tomcat/embed/tomcat-embed-core/8.5.31/tomcat-embed-core-8.5.31.pom[INFO] Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/org/apache/tomcat/embed/tomcat-embed-core/8.5.31/tomcat-embed-core-8.5.31.pom (1.6 kB at 1.4 kB/s)[INFO] Downloading from jcenter-releases: http://jcenter.bintray.com/org/apache/tomcat/embed/tomcat-embed-el/8.5.31/tomcat-embed-el-8.5.31.pom