且构网

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

在 Intellij 上运行测试:找不到类

更新时间:2022-06-15 19:53:52

我浏览了其中一些答案,对项目设置大惊小怪,尝试了一些东西等等,但没有任何效果.(完全披露:我不是想在这里玩弄 Gradle;我只是在使用 Maven,但我不明白这与 Gradle 有什么关系.)

I looked through some of these answers, fussed with Project Settings, tried a few things, etc. and nothing worked. (Full disclosure: I'm not trying to juggle Gradle here; I'm just using Maven, but I don't see what this has to do with Gradle.)

我使用的是 IDEA 14.

I'm using IDEA 14.

我发现可行的方法是:

$ rm -rf .idea project-name.iml

然后重新启动 IntelliJ 并执行 File -> Open -> 导航到我的项目的根目录等等——简而言之,只是重新创建了我的项目.

Then relaunched IntelliJ and did File -> Open -> navigate to the root of my project, etc.--in short, just recreated my project.

IntelliJ 克服了它.我最初可能在这个项目中搞砸了一些东西,因为我已经对包名和类名进行了大量重构,我什至更改了项目名称.(这可能是我的错.)

IntelliJ got over it. I may have messed something up originally in this project as I had done plenty of refactoring both package- and class names and I had even changed the project name. (It was probably my fault it happened.)