克隆后IntelliJ无法识别java项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30088957/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 09:07:07  来源:igfitidea点击:

IntelliJ doesn't recognize java project after cloning

javagitintellij-idea

提问by michalleek

I've cloned my repo from bitbucket and I am trying to open it in IntelliJ IDE, but i can't set Debug Configuration, can't set Main class in Application menu. I can't also add new Java class into project. I think that Intellij can't recognize this project is Java.

我已经从 bitbucket 克隆了我的 repo,我试图在 IntelliJ IDE 中打开它,但我无法设置调试配置,无法在应用程序菜单中设置主类。我也不能在项目中添加新的 Java 类。我认为Intellij无法识别这个项目是Java。

Is it possible to make it right?

有可能使它正确吗?

采纳答案by maba

You have to mark your srcdirectory as Source Root.

您必须将src目录标记为Source Root.

Right-click on the srcfolder and select Sources Root:

右键单击src文件夹并选择Sources Root

enter image description here

在此处输入图片说明

Then you'll see that the icons will change:

然后你会看到图标会发生变化:

enter image description here

在此处输入图片说明





EDIT

编辑

Check the output path by bringing up the Project Structureview.

通过调出Project Structure视图检查输出路径。

Press Ctrl+Alt+Shift+S

Ctrl+ Alt+ Shift+S

enter image description here

在此处输入图片说明

回答by Tyrone Hinderson

Similar to what maba said above, but if applicable you probably want to mark mainand testas source & test source directories (respectively). That's a common project directory structure where literally marking src(parent of mainand test) as source won't work for you.

与 maba 上面所说的类似,但如果适用,您可能希望将main和标记test为源和测试源目录(分别)。这是一个常见的项目目录结构,其中将srcmain和 的父级test)标记为源对您不起作用。