Intellij Idea files with a red circle

匿名 (未验证) 提交于 2019-12-03 08:41:19

问题:

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

回答1:

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'



回答2:

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 Roots documentation.

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:

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

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

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.

Therefore, using our example above, the parent-proj/pom.xml should 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.

<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> 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!