在IntelliJ IDEA中导入Maven依赖项 [英] Import Maven dependencies in IntelliJ IDEA

查看:3157
本文介绍了在IntelliJ IDEA中导入Maven依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于IntelliJ IDEA 11的小问题。我刚刚从subversion导入了一个项目 - 它是一个maven项目。但我在maven库依赖项中遇到问题,因此我无法自动包含所有maven依赖项 - IDEA仅在我打开该类时显示依赖项错误/这就是我得到的内容:

I have a small question about IntelliJ IDEA 11. I just imported a project from subversion - its a maven project. But I have a problem in maven library dependencies so that I can't include all maven dependencies automatically - IDEA shows dependency errors only when I open that class/ Thats what I get here:

所以我希望所有依赖项自动添加 - 是可能的还是我必须通过所有类文件来识别和添加maven依赖项?!

So I want all dependencies to be added automatically - is that possible or do I have to go through all class files to identify and add maven dependencies?!

更新:在做了一些修改之后我找到了如何以某种方式解决我的问题。多数民众赞成我所做的:

UPDATE: After doing some modifications I found how to resolve my problem in some way. Thats what I did:

但我认为逻辑上它不会包括并检查前面的新依赖项?!...在intelliJ中是否有任何设置区域 - 自动导出依赖于类路径?!

but I think logically it will not include and check new dependencies ahead?!... Is there any settings area for this in intelliJ - auto export dependencies to classpath ?!

推荐答案

只要您的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.

这篇关于在IntelliJ IDEA中导入Maven依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆