且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在IntelliJ IDEA中导入Maven依赖项

更新时间:2022-06-13 01:15:55

只要您的POM符合并且所有依赖项都可用,IntelliJ就会自动下载所有依赖项并将其添加到项目的类路径中。

IntelliJ should download and add all your dependencies to the project's classpath automatically as long as your POM is compliant and all the dependencies are available.

将Maven项目导入IntelliJ时,通常会出现一个信息框,询问您是否要为Maven项目配置自动导入。这意味着如果您对POM进行任何更改,那么这些更改将自动加载。

When importing Maven projects into IntelliJ an information box usually comes up asking you if you want to configure Auto-Import for Maven projects. That means that if you make any changes to your POM those changes will be loaded automatically.

您可以启用此类功能转到文件>设置> Maven>导入,有一个复选框,上面写着自动导入Maven项目。

You can enable such feature going to File > Settings > Maven > Importing, there is a checkbox that says "Import Maven projects automatically".

如果这没有帮助,那么我建议进行全面清理并重新开始:

If that doesn't help, then I would suggest to make a full clean-up and start again:


  • 关闭项目窗口(和IntelliJ)并删除所有 * .iml 文件和所有文件 .idea 文件夹(每个模块应该有一个)

  • 运行 mvn clean install 从命令行

  • 将项目重新导入IntelliJ并在要求您启用自动导入时注意

  • Close your project window (and IntelliJ) and remove all *.iml files and all .idea folders (there should be one per module)
  • Run mvn clean install from the command line
  • Re-import the project into IntelliJ and pay attention when it asks you to enable auto-import

IntelliJ 2016更新

自动导入Maven项目设置已设置移至IntelliJ首选项中的构建,执行,部署>构建工具> Maven>导入

The Import Maven Projects automatically setting has been moved to Build, Execution, Deployment > Build Tools > Maven > Importing in your IntelliJ preferences.