IntelliJ not seeing resources folder

為{幸葍}努か 提交于 2019-12-04 02:52:17

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.

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

master

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.

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)

Had similar issue. Solution that worked for me:

ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource("path").getFile());
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!