如何配置 eclipse 中的 maven
步骤 1:安装 Maven
从官方 Maven 网站下载并安装 Maven。
步骤 2:配置 Eclipse
- 启动 Eclipse,转到 Window > Preferences。
- 在左侧导航栏中,展开 Maven 节点。
- 在 User Settings 下,单击 Add。
- 浏览到 Maven 安装目录中
conf/settings.xml文件。 - 在 Global Settings 下,单击 Add。
- 浏览到 Maven 安装目录中
conf/settings.xml文件。 - 单击 Apply 和 OK 保存更改。
步骤 3:创建 Maven 项目
- 在 File > New > Other 中,找到并选择 Maven Project。
- 在向导中,选择 Create a simple project (skip archetype selection)。
- 单击 Next。
- 输入 GroupId、ArtifactId 和 Version。
- 单击 Finish。
步骤 4:配置 Maven 依赖项
- 在项目的 pom.xml 文件中,找到
节点。 - 添加以下示例依赖项:
junit junit 4.13.2 test
- 保存文件。
步骤 5:构建项目
- 在项目上右键单击,然后选择 Run As > Maven Build。
- 在 Goals 字段中,输入:
clean install
- 单击 Run 开始构建。
提示:
- 如果出现版本冲突,请在 Eclipse 中更新 Maven 设置中的 Repository Server List。
- 确保在构建路径上正确配置了 Maven 依赖项。
- 有关详细说明,请参阅 Eclipse 文档和 Maven 网站。










