在IntelliJ中构建应用程序时遇到问题。
如果我有2个模块:
应用程序; application.gui
在应用程序gui中ressources文件夹下,我有一个图像/layout/image/background.jpg
在此模块中,将此图像称为“我不知道它不存在”。这只是IntelliJ打包问题,因为在maven中构建的同一项目工作正常。
我应该如何配置IntelliJ使其起作用?
https://gitlab.com/mszymkowiak/simgentree/tree/simgentree-start/simgentree.project
与How to access a resource file in src/main/resources/ folder in Spring Boot无关
因为IntelliJ构建的文件可能不可见。我已经尝试过这种解决方案,并且它的子模块始终返回null。 我在intelliJ中的Java11中的JavaFX应用程序中遇到相同的问题 (java8中的同一应用程序可以正常工作,但是当从IntelliJ运行它时,来自子模块的任何资源都不可见)
System.out.println("Empty path exist ? : "+ resourceLoader.getResource("").exists());
System.out.println("mainbackground path exits ? : " +resourceLoader.getResource("layout/images/mainbackground.jpg").exists());
礼物:
Empty path exist ? : false
mainbackground path exits ? : false
@编辑 我将文件添加到名为:static的资源文件夹中,并将文件移动到该文件夹中,这似乎可行。但是我想知道,为什么当静态不存在时它不起作用