编辑系统环境
/etc/profile
手动安装指定版本(适合需要特定版本的场景)
若包管理器中的 Maven 版本不符合需求(如项目要求 3.8.x 或更高),可手动安装:
1. 安装依赖 JDK
Maven 依赖 Java 环境,先确保已安装 JDK(以 OpenJDK 1.8 为例):
bash
sudo dnf install -y java-1.8.0-openjdk-devel
java -version # 验证 Java 安装
2. 下载 Maven 二进制包
从 Maven 官网 复制最新版或指定版本的下载链接(以 3.9.6 为例):
下载地址
bash
# 创建安装目录
sudo mkdir -p /usr/local/maven
# 下载并解压
wget https://dlcdn.apache.org/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz
sudo tar -zxvf apache-maven-3.9.6-bin.tar.gz -C /usr/local/maven --strip-components=1
3. 配置环境变量
编辑 /etc/profile
(全局生效)或 ~/.bashrc
(当前用户生效):
bash
sudo nano /etc/profile
在文件末尾添加:
bash
export MAVEN_HOME=/usr/local/maven
export PATH=$MAVEN_HOME/bin:$PATH
保存后使配置生效:
bash
source /etc/profile
4. 验证安装:
bash
mvn -version
输出示例:
plaintext
Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08ccf28cc506)
Maven home: /usr/local/maven
Java version: 1.8.0_382, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.382.b05-1.al8.x86_64/jre
...
阿雪技术观
在科技发展浪潮中,我们不妨积极投身技术共享。不满足于做受益者,更要主动担当贡献者。无论是分享代码、撰写技术博客,还是参与开源项目维护改进,每一个微小举动都可能蕴含推动技术进步的巨大能量。东方仙盟是汇聚力量的天地,我们携手在此探索硅基生命,为科技进步添砖加瓦。
Hey folks, in this wild tech - driven world, why not dive headfirst into the whole tech - sharing scene? Don't just be the one reaping all the benefits; step up and be a contributor too. Whether you're tossing out your code snippets, hammering out some tech blogs, or getting your hands dirty with maintaining and sprucing up open - source projects, every little thing you do might just end up being a massive force that pushes tech forward. And guess what? The Eastern FairyAlliance is this awesome place where we all come together. We're gonna team up and explore the whole silicon - based life thing, and in the process, we'll be fueling the growth of technology.