Apache Maven是一种流行的构建自动化工具,用于基于Java的软件开发项目。它通过管理项目依赖项、定义构建生命周期和阶段以及支持插件来简化构建过程。如果您正在处理Java项目,那么绝对值得考虑使用Apache Maven来简化构建过程并简化开发工作流程。
在Linux Mint 21上安装Apache Maven Vanessa
第 1 步。在运行下面的教程之前,请务必通过在终端中运行以下命令来确保您的系统是最新的:apt
<span class="pln">sudo apt update sudo apt install software</span><span class="pun">-</span><span class="pln">properties</span><span class="pun">-</span><span class="pln">common apt</span><span class="pun">-</span><span class="pln">transport</span><span class="pun">-</span><span class="pln">https wget ca</span><span class="pun">-</span><span class="pln">certificates gnupg2</span>
第 2 步。安装爪哇。
Apache Maven 需要在您的系统上安装 Java 开发工具包 (JDK)。如果您的系统上没有安装 JDK,则可以使用以下命令进行安装:
<span class="pln">sudo apt install </span><span class="kwd">default</span><span class="pun">-</span><span class="pln">jdk</span>
有关安装 Java 的其他资源,请阅读下面的帖子:
- 如何在Linux Mint √上安装Java
第 3 步。在Linux Mint 21上安装Apache Maven。
默认情况下,Apache Maven 在 Linux Mint 21 基础存储库中可用。现在运行以下命令,将Maven的最新稳定版本下载到Linux Mint系统:
<span class="pln">wget https</span><span class="pun">:</span><span class="com">//dlcdn.apache.org/maven/maven-3/3.9.0/binaries/apache-maven-3.9.0-bin.tar.gz</span>
接下来,使用以下命令提取下载的文件:
<span class="pln">tar </span><span class="pun">-</span><span class="pln">xvf apache</span><span class="pun">-</span><span class="pln">maven</span><span class="pun">-</span><span class="lit">3.9</span><span class="pun">.</span><span class="lit">0</span><span class="pun">-</span><span class="pln">bin</span><span class="pun">.</span><span class="pln">tar</span><span class="pun">.</span><span class="pln">gz</span>
第 4 步。配置环境变量。
要使用 Apache Maven,您需要设置 and 环境变量。您可以通过向文件添加以下行来设置这些变量:PATH
JAVA_HOME
~/.bashrc
<span class="kwd">export</span><span class="pln"> JAVA_HOME</span><span class="pun">=</span><span class="str">/usr/</span><span class="pln">lib</span><span class="pun">/</span><span class="pln">jvm</span><span class="pun">/</span><span class="kwd">default</span><span class="pun">-</span><span class="pln">java </span><span class="kwd">export</span><span class="pln"> PATH</span><span class="pun">=</span><span class="pln">$PATH</span><span class="pun">:</span><span class="str">/path/</span><span class="pln">to</span><span class="pun">/</span><span class="pln">apache</span><span class="pun">-</span><span class="pln">maven</span><span class="pun">-</span><span class="lit">3.9</span><span class="pun">.</span><span class="lit">0</span><span class="pun">/</span><span class="pln">bin</span>
确保将 “” 替换为 Apache Maven 安装目录的实际路径。若要应用更改,请运行以下命令:/path/to
<span class="pln">source </span><span class="pun">~/.</span><span class="pln">bashrc</span>
要验证 Maven 是否已安装并正常工作,请运行以下命令:
<span class="pln">mvn </span><span class="pun">-</span><span class="pln">version</span>
感谢您使用本教程在Linux Mint系统上安装最新版本的Apache Maven。有关其他帮助或有用信息,我们建议您查看 Apache 官方网站。