Best practices to store and access resource files in java web application

谁说我不能喝 提交于 2019-11-30 14:13:13

It's perfectly fine to load static resources using the classloader. That's what ResourceBundle does to load the internationalized properties files for example.

Put them in WEB-INF/classes along with your class files, or in a jar inside WEB-INF/lib, and load them with the ClassLoader as indicated by the answers you already read.

That doesn't forbid you to place these files in a separate directory from the Java source files in your project. The build process should just make sure to put them in the appropriate location for runtime. The Maven and Gradle convention is to put the source files under src/main/java and the resource files under src/main/resources.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!