在 Maven 项目中添加依赖的方法有以下几种:
在项目的 pom.xml 文件中手动添加依赖块。在<dependencies> 标签内添加 <dependency> 标签,并填写依赖的坐标信息。例如:<dependencies> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.12.0</version> </dependency></dependencies>使用 Maven 命令行工具添加依赖。通过使用 mvn dependency:copy-dependencies 命令可以将依赖添加到项目中。
使用 Maven 项目管理工具(例如 IntelliJ IDEA、Eclipse)的图形界面来添加依赖。通常可以在 Maven 项目的 pom.xml 文件中找到一个依赖管理的选项,通过点击添加按钮来搜索和选择需要的依赖。
无论使用哪种方法,当添加依赖后,Maven 会自动下载依赖并将其添加到项目的 classpath 中,以便在项目中使用。

