IntelliJ not seeing resources folder

28,296

Solution 1

There is a bug in Intellij 12 please go to Settings->Compiler and un-check "Use external build" check box - the idea behind it was that it was suppose to run faster with a compiler run in a separate process but in fact there is a bug and when using maven it does not copy resources.

Solution 2

Right Click the Directory -> "Mark Directory as" -> "Resource Root"

Solution 3

Well the answer is quite simple ..!
Just reference the file path in your source code as below:

src\\main\\resources\\FileName

& it should work as expected.

Solution 4

try

<resources>
  <resource>
    <directory>src/main/resources</directory>
    <includes>
      <include>**/*</include>
    </includes>
  </resource>
</resources>

or under settings -> compiler -> resource patterns, add the resource pattern (i.e ?*.prefs)

Share:
28,296
Marsellus Wallace
Author by

Marsellus Wallace

The real Marsellus Wallace

Updated on July 20, 2021

Comments

  • Marsellus Wallace
    Marsellus Wallace almost 3 years

    I created a new Project from scratch in IntelliJ by using a Maven Module. I didn't select any specific archetypes and I clicked on finish. The project gets created nicely and I have the java and resources folders under src/main as expected.

    Unfortunately, my application does not find any property files in the resources folder because it looks in the project base folder instead.

    I double checked that the resources folder is marked as 'source folder' in the Project Structure and I also tried to add the following to the pom.xml with no success:

    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
    

    I'm using Maven 2.2.1 and IntelliJ 11.1, Any thoughts??

    • Ilya
      Ilya over 11 years
      IDEA community edition 11.1.2 works well. Custom resource dirs not seem, but default dir 'src/main/resources' see well
    • CrazyCoder
      CrazyCoder over 11 years
    • Eugen Martynov
      Eugen Martynov over 11 years
      What kind of resources do you have there? If it something custom types (*.bin, etc) you have to specify compiler to include these files
    • Jesse Webb
      Jesse Webb over 11 years
      Can you show us a screenshot or typed text-version of your project's directory structure?
    • Jesse Webb
      Jesse Webb over 11 years
      One other thing to try... IDEA project creation sucks, unfortunately. I always use mvn command line with archetype:generate to create new projects. Then I use the POM file as a way to create a new IDEA project with existing sources (I think). If you have a pom, try deleting all your IDEA project files (.ipr, .iml, .idea, etc) and then creating a new IDEA project using the POM file. See what happens...
  • cooltea
    cooltea over 10 years
    Link to a relevant entry in IntelliJ issue tracker mentioning the fix: youtrack.jetbrains.com/issue/IDEA-97759
  • Aditya
    Aditya over 9 years
    For those using IntelliJ IDEA 13, external build is the only option available since the older compiler has been removed. Thus, you won't find any checkbox for "Use external build".