Ubuntu2004安装maven制作容器镜像

一、安装配置maven

访问maven官网:https://archive.apache.org/dist/maven/maven-3/

1
2
3
4
5
6
7
#下载
root@dify:/opt/instakkPkgs# wget https://archive.apache.org/dist/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.tar.gz

#解压
root@dify:/opt/instakkPkgs# mkdir /opt/maven
root@dify:/opt/instakkPkgs# tar xzvf apache-maven-3.8.1-bin.tar.gz -C /opt/maven
root@dify:/opt/instakkPkgs# cd /opt/maven/apache-maven-3.8.1/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#配置阿里镜像
root@dify:/opt/maven/apache-maven-3.8.1# vi conf/settings.xml
...
146 <mirrors>
147 <!-- mirror
148 | Specifies a repository mirror site to use instead of a given repository. The repository that
149 | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
150 | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
151 |
152 <mirror>
153 <id>mirrorId</id>
154 <mirrorOf>repositoryId</mirrorOf>
155 <name>Human Readable Name for this Mirror.</name>
156 <url>http://my.repository.com/repo/path</url>
157 </mirror>
158 -->
159 <mirror>
160 <id>aliyunmaven</id>
161 <mirrorOf>central</mirrorOf>
162 <name>aliyun maven</name>
163 <url>https://maven.aliyun.com/repository/public</url>
164 </mirror>
165 <!-- <mirror>
166 <id>maven-default-http-blocker</id>
167 <mirrorOf>external:http:*</mirrorOf>
168 <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
169 <url>http://0.0.0.0/</url>
170 <blocked>true</blocked>
171 </mirror>
172 -->
173 </mirrors>
...
1
2
3
4
5
6
7
#将maven bin目录加入系统PATH
root@dify:/opt/maven/apache-maven-3.8.1# vi /root/.bashrc
export M2_HOME=/opt/maven/apache-maven-3.8.1
export PATH=$PATH:$M2_HOME/bin

#加载设置的变量
root@dify:/opt/maven/apache-maven-3.8.1# source /root/.bashrc
1
2
3
4
5
6
#验证
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /opt/maven/apache-maven-3.8.1
Java version: 11.0.25, vendor: Oracle Corporation, runtime: /usr/local/jdk-11.0.25
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-102-generic", arch: "amd64", family: "unix"

二、制作容器镜像


Ubuntu2004安装maven制作容器镜像
https://jiangsanyin.github.io/2025/03/21/Ubuntu2004安装maven制作容器镜像/
作者
sanyinjiang
发布于
2025年3月21日
许可协议