Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.8K
Views
Java file outside of source root 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.

over 4 years ago · Santiago Trujillo
14 answers
Answer question

0

I faced the same problem in one of the modules in my multi module maven project. In my InteliJ idea, I've installed Maven Helper plugin before. I did right click on the module and within that contextual menu click Run Maven and then Reimport. After doing that, my issue resolved.

over 4 years ago · Santiago Trujillo Report

0

I fixed it using this way:

File > Project Structure > Modules > Sources

and then marked java files dir as Sources.

over 4 years ago · Santiago Trujillo Report

0

To Solve: "Java file outside of source root"

  1. Open Project Structure.
  2. Select Modules in Project Settings in left pane.
  3. Click on the folder in which your Java files (showing file outside of source root) are present.
  4. Then Select Sources from Mark as: option.
  5. Apply the same steps for multiple folders.
over 4 years ago · Santiago Trujillo Report

0

Go to

File >>Project Structure>>Modules>> Import Module>>  (At this point your src folder will appear on the right most pane automatically ) >> Apply >> OK
over 4 years ago · Santiago Trujillo Report

0

This has been driving me quite mad and I am a newbie as well. I finally solved it by using:

file > project structure >

Then going to Modules and removing all the files from the root using the x marks on the far right. I then used the +Add Content Root to reselect the src folders that contained my .java and hit Apply. Finally InteliJ sees the files as in the project and the folders gain the blue square on the main view.

over 4 years ago · Santiago Trujillo Report

0

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

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.

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

over 4 years ago · Santiago Trujillo Report

0

Very simple solution :-

Click on "maven" on the right toolbar in IntelliJ and then click on the refresh button.

over 4 years ago · Santiago Trujillo Report

0

Right click on pom.xm >> maven >> Reload project

over 4 years ago · Santiago Trujillo Report

0

In intellij: click Maven, select the project and right, select Unignore Projects

over 4 years ago · Santiago Trujillo Report

0

I had to open the module I worked on to a new window to solve that.

over 4 years ago · Santiago Trujillo Report

0

Hate to add yet another method; but this one worked for me after trying and failing with the above methods. I had a multi-mode project. Unlinked all maven projects in Maven workspace and reloaded as maven project by clicking root poom.xml in project workspace. Not sure whether this will always work and for everyone.

over 4 years ago · Santiago Trujillo Report

0

For ppl like me who also see that the POM file is crossed out and greyed(ignored):

You can right click the POM.xml, select "Maven - Unignore projects".

over 4 years ago · Santiago Trujillo Report

0

I'm just gonna throw my solution to this problem in here, since none of the above worked:

If there are multiple pom files in your project, on the Maven sidebar to the right, click the plus ('+') button and navigate to the other pom file that does not have the Maven ('M') icon next to it in the project structure of your project (left sidebar).

Then click 'OK' - this then loads all the Maven dependencies from the unused pom file and, for me, everything was finally fixed!

Maven sidebar > plus icon (+) > direct to other pom file > 'ok'

over 4 years ago · Santiago Trujillo Report

0

IntelliJ may be ignoring files from a multi-module project. Modules that are ignored will make it harder for the IDE to find the root of that file. Hence, java file outside of source root

Another solution:

Preferences -> Build, Execution, Deployment -> Build Tools -> Maven -> Ignored Files

Now, uncheck the modules you do not want IntelliJ to ignore.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!