java 带有红色圆圈的 Intellij Idea 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30131939/
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-11-02 16:31:44  来源:igfitidea点击:

Intellij Idea files with a red circle

javaintellij-idea

提问by Hello

My Intellij Idea file names in the Project Explorer all have a small Red circle with "J" written on them. What would that represent?

我在项目资源管理器中的 Intellij Idea 文件名都有一个红色的小圆圈,上面写着“J”。那代表什么?

回答by Software Engineer

IntelliJ recognises that this is a java file, but it's not marked as part of the project source. Check that your project is following the maven standards, and if not configure the pom to tell it where your sources are. You can fix this temporarily in IntelliJ by right clicking on the source root (that's 'java' in the maven standards) and choosing to 'Mark Directory As --> Source Root'

IntelliJ 识别出这是一个 java 文件,但未将其标记为项目源的一部分。检查您的项目是否遵循 maven 标准,如果没有,请配置 pom 以告诉它您的来源在哪里。您可以在 IntelliJ 中通过右键单击源根目录(即 maven 标准中的“java”)并选择“将目录标记为-> 源根目录”来临时修复此问题

回答by whyceewhite

When you create a module, typically it has one content root. You can create additional (and remove) content roots as explained in IntelliJ's Configuring Content Rootsdocumentation.

当您创建一个模块时,通常它有一个内容根。您可以按照 IntelliJ 的配置内容根文档中的说明创建其他(和删除)内容根。

However, it is possible that you imported a maven project that contains modules. In other words, you have a directory structure with sub-modules as shown below:

但是,您可能导入了包含模块的 Maven 项目。换句话说,您有一个包含子模块的目录结构,如下所示:

parent-proj/
|
|--module-a-proj/
|  |-- src/
|  |-- pom.xml
|
|--module-b-proj/
|  |-- src/
|  |-- pom.xml
|
|-- pom.xml

If you look in the parent-proj/pom.xmlyou should see a <modules></modules>section. If your <modules>contains your sub-modules (such as module-a-projand module-b-projin our example above) then IntelliJ will properly add their srcdirectories as content roots.

如果你查看parent-proj/pom.xml你应该看到一个<modules></modules>部分。如果<modules>包含您的子模块(如module-a-projmodule-b-proj在上面的例子中),那么会的IntelliJ添加适当的src目录,内容的根。

On the other hand, if the sub-modules are not included in the parent pom then you might see the red symbol that indicates Java class located out of the source root.

另一方面,如果子模块未包含在父 pom 中,那么您可能会看到红色符号,表示位于源根之外的 Java 类

Therefore, using our example above, the parent-proj/pom.xmlshould look something like the pom example below. The pom example is intentionally sparse and is for demonstration purposes only. In particular, pay attention to the <modules>section.

因此,使用我们上面的示例,parent-proj/pom.xml应该类似于下面的 pom 示例。pom 示例故意稀疏并且仅用于演示目的。尤其要注意<modules>节。

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.your.groupid</groupId>
    <artifactId>parent-proj</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
        <module>module-a-proj</module>
        <module>module-b-proj</module>
    </modules>

    <dependencies></dependencies>
</project>

回答by anayagam

what worked for me : Since I did a git pull but the cache was still from an older version all I did was invalidate the caches and rebuilt the project in Intellij

什么对我有用:因为我做了一个 git pull 但缓存仍然来自旧版本,所以我所做的只是使缓存无效并在 Intellij 中重建项目

enter image description here

在此处输入图片说明

回答by yogesh joshi

For me the issue was intelliJ was ignoring .pom files, somehow (Don't know why) Unchecked the checkbox to consider it and not ignore. and started working

对我来说,问题是 intelliJ 忽略了 .pom 文件,不知何故(不知道为什么)取消选中复选框以考虑它而不是忽略。并开始工作

File -> setting -> Build,Execution, deployment ->maven ->ignore files

文件 -> 设置 -> 构建、执行、部署 -> maven -> 忽略文件