简体   繁体   English

克隆后IntelliJ无法识别java项目

[英]IntelliJ doesn't recognize java project after cloning

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.我已经从 bitbucket 克隆了我的 repo,我试图在 IntelliJ IDE 中打开它,但我无法设置调试配置,无法在应用程序菜单中设置主类。 I can't also add new Java class into project.我也不能在项目中添加新的 Java 类。 I think that Intellij can't recognize this project is Java.我认为Intellij无法识别这个项目是Java。

Is it possible to make it right?有可能使它正确吗?

You have to mark your src directory as Source Root .您必须将src目录标记为Source Root

Right-click on the src folder and select Sources Root :右键单击src文件夹并选择Sources Root

在此处输入图片说明

Then you'll see that the icons will change:然后你会看到图标会发生变化:

在此处输入图片说明



EDIT编辑

Check the output path by bringing up the Project Structure view.通过调出Project Structure视图检查输出路径。

Press Ctrl + Alt + Shift + SCtrl + Alt + Shift + S

在此处输入图片说明

Similar to what maba said above, but if applicable you probably want to mark main and test as source & test source directories (respectively).与 maba 上面所说的类似,但如果适用,您可能希望将maintest标记为源和测试源目录(分别)。 That's a common project directory structure where literally marking src (parent of main and test ) as source won't work for you.这是一个常见的项目目录结构,其中将srcmaintest父级)字面标记为源对您不起作用。

Yes, marking src folder as 'Source Root' resolved the issue.是的,将src文件夹标记为“源根目录”解决了这个问题。 Earlier intellij was not detecting java files.早期的 Intellij 没有检测到 Java 文件。

Go to: Right Click --> src --> (Choose option) Mark Directory as --> Source Root.转到:右键单击 --> src -->(选择选项)将目录标记为 --> 源根目录。

As a footnote, I've had what I thought of as small projects take well over 15 minutes to fully load into IntelliJ, and during this time the little status bar in the bottom right seems to be downloading dependencies (lots of Spring stuff) ... though most of them should have already been in my local ~/.m2 maven repo.作为脚注,我认为小项目需要 15 多分钟才能完全加载到 IntelliJ 中,在此期间,右下角的小状态栏似乎正在下载依赖项(很多 Spring 内容)。 ..虽然他们中的大多数应该已经在我本地的 ~/.m2 maven repo 中。

Maybe slow network, maybe the repo/proxy I was hitting was slow ... whatever, I'm just reminding people to check that status bar when opening a new project.也许网络缓慢,也许我正在使用的回购/代理很慢......无论如何,我只是提醒人们在打开新项目时检查该状态栏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM