简体   繁体   中英

How to set resources folder in Intellij ide - java

I have an issue that I am trying to solve a while. I have a project that I imported using intelilj ide. I want to use a file that exists in my resources folder. The problem is that Intellij set the resource folder in wrong place. This is the command in java

 ClassLoader classLoader = getClass().getClassLoader();
        String path = classLoader.getResource("fw8TAX12.pdf").getPath();

this is what Intelij returns:

X:\project\out\test\resources

however the file in in

   X:\project\src\test\resources

I do not understand what is the out folder in my project since I did not create it, I need that getResource method return the accurate place of the resource.

I navigate to modules in intelij and under Resources and test resources tab, select the correct path, and nothing intelij just goes to the out folder and not to the src folder. how can I make intelij understand what is the correct resources path

在此处输入图像描述

在此处输入图像描述

another try to set the resource folder that not worked在此处输入图像描述

In project frame, right click directory -> mark as -> Resources. Or click the Resources button in the header in your first screen shot (with that directory selected as shown).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM