IntellijIDEA无法识别Maven依赖项中指定的类 [英] IntellijIDEA not recognizing classes specified in Maven dependencies

查看:894
本文介绍了IntellijIDEA无法识别Maven依赖项中指定的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IntellijIDEA中有一个用Maven创建的项目。然后我在Pom.xml文件中指定了一组依赖项和外部存储库。

I have a project in IntellijIDEA which was created with Maven. I then specified a set of dependencies and external repositories in the Pom.xml file.

如果我执行mvn install,项目在命令行上构建正常。当我在IDE中打开任何代码文件时,虽然它表示Maven依赖项处理的所有类都无法识别 - 如果我从未将所需的JAR添加到构建路径中那么它将用于普通项目。

The project builds fine on command line if I do "mvn install". When I open any of the code files in the IDE though it says all the classes handled by Maven dependencies aren't recognized - as it would for a normal project if I never added the required JARs to the build path.

我知道在我的Eclipse Maven项目(而不是IntelliJ)中,它通常在左边显示一个额外的目录,上面写着Maven Dependencies并列出了通过maven引入的JAR。我在这里看不到。我做错了什么?

I know in my Eclipse Maven projects (rather than IntelliJ) it usually shows an extra directory on the left which says "Maven Dependencies" and lists the JARs pulled in via maven. I don't see that here. What am I doing wrong?

以下是我的屏幕:

推荐答案

由于某种原因,重新导入并没有成功。看完之后:

For some reason re-import did not do the trick. After looking at this:

http:// www.jetbrains.com/idea/webhelp/maven-importing.html

我设置自动导入然后问题就消失了;希望它能帮助别人。感谢大家的想法:)。

I set auto-import and then the problem went away though; hopefully it helps someone else. Thanks for the ideas everyone :).

这篇关于IntellijIDEA无法识别Maven依赖项中指定的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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