源根 intelliJ 之外的 Java 文件 [英] Java file outside of source root intelliJ

查看:55
本文介绍了源根 intelliJ 之外的 Java 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 GitLab 克隆了一个 Spring Boot 项目,该项目在 IntelliJ 中有多个分支.我结帐到我想工作的分支机构.但是我得到了源根目录之外的 Java 文件"在所有文件上.请建议我做错了什么.我刚刚安装了 IntelliJ,这是我要导入的第一个项目.

I have cloned a spring boot project from GitLab having multiple branches in IntelliJ. I checkout to the branch in which I want to work. But I am getting "Java file outside of source root" on all the files. Please suggest what I am doing wrong. I just installed IntelliJ and it's the first project that I am importing.

推荐答案

如果您执行从 git 导入",IntelliJ 不会自动从 maven(或 gradle)导入项目结构.

If you do an 'import from git', IntelliJ doesn't import the project structure from maven (or gradle) automatically.

之后执行此操作的一种方法是右键单击根目录中的 pom.xml 文件,然后选择添加为 maven 项目".然后将正确标记文件夹,并导入依赖库.无需手动标记单个源文件夹.

One way to do this afterwards is to right-click on the pom.xml file in the root directory, and select 'Add as maven project'. Then the folders will be marked correctly, and dependent libraries will be imported. There should be no need to mark individual source folders manually.

我更喜欢在 IntelliJ 之外做一个 git clone,从本地文件系统打开项目,然后 IntelliJ 自动导入 maven 项目结构.

I prefer to do a git clone outside of IntelliJ, and open the project from the local filesystem, then IntelliJ imports the maven project structure automatically.

这篇关于源根 intelliJ 之外的 Java 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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