此内容没有您所选择的语言版本。

2.2. Install Maven


Maven is a build system for projects that use the Project Object Model (POM). It downloads package dependencies quickly and easily. If you have an infrastructure team providing your Red Hat JBoss Data Virtualization environment, you can skip this procedure. Otherwise, you will need to follow it to install Maven to build your projects.
Prerequisites

The following software must be installed:

  • An archiving tool for extracting the contents of compressed files.
  • Open JDK.

Procedure 2.1. Install Maven

  1. Download Maven.

    1. Download the apache-maven-[latest-version] ZIP file.
  2. Install and configure Maven.

    • On Red Hat Enterprise Linux

      1. Extract the ZIP archive to the directory where you wish to install Maven.
      2. Open your .bash_profile file:
        vi ~/.bash_profile
      3. Add the M2_HOME environment variable to the file:
        export M2_HOME=/path/to/your/maven
      4. Add the M2 environment variable to the file:
        export M2=$M2_HOME/bin
      5. Add the variable $JAVA_HOME/bin to set the path to the correct Java installation.

        Note

        Make sure JAVA_HOME is pointing to a valid location.
      6. Add the M2 environment variable to the file:
        export PATH=$M2:$PATH
      7. Save the file and exit your text editor.
      8. Reload your profile:
        source ~/.bash_profile
      9. Run the following command to verify that Maven is installed successfully on your machine:
        mvn --version
    • On Microsoft Windows

      1. Extract the ZIP archive to the directory where you wish to install Maven. The subdirectory apache-maven-[latest-version] is created from the archive.
      2. Press Start+Pause|Break. The System Properties dialog box is displayed.
      3. Click the Advanced tab and click Environment Variables.
      4. Under System Variables, select Path.
      5. Click Edit and add the two Maven paths using a semicolon to separate each entry.
        • Add the M2_HOME variable and set the path to C:\path\to\your\Maven.
        • Add the M2 variable and set the value to %M2_HOME%\bin.
      6. Update or create the Path environment variable:
        • Add the %M2% variable to allow Maven to be executed from the command line.
        • Add the variable %JAVA_HOME%\bin to set the path to the correct Java installation.
      7. Click OK to close all the dialog boxes including the System Properties dialog box.
      8. Open Windows command prompt and run the following command to verify that Maven is installed successfully on your machine:
        mvn --version
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部