只要您的POM兼容并且所有依赖项都可用,IntelliJ就应该自动下载所有依赖项并将其添加到项目的类路径中.
将Maven项目导入IntelliJ时,通常会出现一个信息框,询问您是否要为Maven项目配置Auto-Import.这意味着,如果您对POM进行任何更改,这些更改将自动加载.
You can enable such feature going to File > Settings > Maven > Importing, there is a checkbox that says "Import Maven projects automatically".
如果这没有帮助,那么我建议进行全面清理,然后重新开始:
- 关闭项目窗口(和IntelliJ),删除所有
*.iml
个文件和所有.idea
个文件夹(每个模块应有一个)
- 从命令行运行
mvn clean install
- 将项目重新导入到IntelliJ中,当它要求您启用自动导入时请注意
IntelliJ 2016 Update:
The Import Maven Projects automatically setting has been moved to Build, Execution, Deployment > Build Tools > Maven > Importing in your IntelliJ preferences.