24

All my classes were working fine. Then I wanted to create main/resources to add logback.xml in main/resources in my project

I got help from "How to create main/java inside src"

But after creating the folders I am getting errors in all my classes, and the main folders were converted into packages

directory structure

How can I add the folder main/resources in my src folder?

Or is there any way to add logback.xml in any package in spring MVC?

Community
  • 1
  • 1
Kunal Batra
  • 821
  • 3
  • 14
  • 35

10 Answers10

35

To add a resource folder in eclipse:

  • Click on Build Path

  • Click on Configure Build Path

    (or Properties -> Java Build Path)

  • Click on Source Tab

    enter image description here

    Click on Add Folder

    enter image description here

  • Click on Create new Folder
  • Jad Chahine
    • 6,849
    • 8
    • 37
    • 59
    9

    The same problem I also encountered while I was learning the spring boot wanted to add logback.xml in resources. I am using sts for spring boot. As of my understanding, there are two things your file system folder structure and another sts folder structure. First I created a folder in your file system at src/main/ and then add this folder into build path. *


    For creating a folder follow below image 1,2 and 3

    * image 1

    image 2

    image 3

    Now at the final step, add newly added resource folder into the build path. by clicking properties or directly build path button. Click on source tab and then click on add folder and browse the resources folder and add that's all. See below image for more description and help. image 4

    Mukesh Kumar Gupta
    • 1,567
    • 20
    • 15
    • I tried this one and it work very well for me. Just refresh your maven update and folder is available under the right location in eclise. – H Roy Dec 17 '19 at 06:15
    5

    Right Click your project -> Build Path -> New Source Folder and Type the name of the the resource folder you want to create like ----->src/main/resources or src/test/resources ..it will create a new resource folder

    Sweety Sharma
    • 121
    • 1
    • 2
    • 3
    3

    Try to add new Source Folder. Right click on your src->New>Source Folder:main/resources

    Roxana Roman
    • 1,012
    • 1
    • 8
    • 17
    • 2
      it ll create folder in java resources folder not in src – KhAn SaAb Apr 28 '16 at 06:54
    • That's because src is not configured as a source folder in your project. Java Resources is. You should use a Source folder for your classes. If you want to convert src folder to a source folder right click on source -> Build Path and select Use as Source Folder – Roxana Roman Apr 28 '16 at 07:32
    2

    Right Click your project -> Build Path -> New Source Folder

    Type the folder path, src/main/resources and click Finish.

    Screenshots below.

    Step 1: Figure: 1

    Step 2: Figure: 2

    Daniel Raja
    • 53
    • 1
    • 1
    • 5
    1

    Since you're not using Maven, you shouldn't be creating the src/main/resources folder. Just put logback.xml in the src folder.

    Also move your java files (with their entire package folder structure) back to src as they were before creating the main/resources.

    Nazaret K.
    • 3,409
    • 6
    • 22
    • 31
    1

    Only maven project automatically generate resource folder inside src, other solution would be put logbackback.xml in src folder it ll work.

    KhAn SaAb
    • 5,248
    • 5
    • 31
    • 52
    1

    Locate your pom.xml. Navigate to the build tag in it. Inside this tag you will have to look for any declaration regarding your source directory. Might be sourceDirectory direclty, or it might appear in any of plugin as well. Upon finding so, try un-commenting the same and do a Right Click->Maven->Update Project. Should solve for most cases. If not you have some other issue.

    soufrk
    • 825
    • 1
    • 10
    • 24
    0

    maybe you could created the new folder.Then,opening this object's properties and clicking 'Java Build Path'.Reelecting the source folder on build path.Just try,man!

    Ray Q
    • 11
    • 1
    0

    If your project is eclipse project then it will automatically recognize the folders
    Open command line, change directory to the folder with the pom.xml
    and past this into the CMD:

    echo This will create all required folders for maven project.
    echo creating  Application\Library sources
    MD "src\main\java"
    echo creating  Application\Library resources
    MD "src\main\resources"
    echo creating  Resource filter files
    MD "src\main\filters"
    echo creating  Web application sources
    MD "src\main\webapp"
    echo creating  Test sources
    MD "src\test\java"
    echo creating  Test resources
    MD "src\test\resources"
    echo creating  Test resource filter files
    MD "src\test\filters"
    echo creating  Integration Tests (primarily for plugins)
    MD "src\it"
    echo creating  Assembly descriptors
    MD "src\assembly"
    echo creating  Site
    MD "src\site"
    
    JavaSheriff
    • 7,074
    • 20
    • 89
    • 159