Grails 项目中的资源应该放在哪里?
我想知道 Grails 应用程序中是否有指定的资源文件位置?我有一个 csv 文件,已加载到地图中(没什么大不了的),但不太知道将其放在项目中的何处。
所以我的问题是,项目中有没有专门的地方来放置这个文件? (如果是,在哪里?)或者将其放在项目之外更好?
I am wondering if there is a designated place for resource files in a Grails application? I have a csv file that gets loaded into a map (nothing major) but didn't quite know where to put it in the project.
So my question is, is there a dedicated place in the project to place this file? (If so, where?) Or is it better to place it outside of the project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 csv 需要不时更新,我会将其放在 grails 文件夹外部,并从 config.groovy 指向它。
如果它基本上是一个静态文件,我会将其放入 src/java/resources 中,并使用类似 this.class.getResource("/resources/file.csv") 的内容加载它,就像使用常规 java 应用程序一样
If the csv is going to need updating from time to time, I'd put it external to your grails folder, and point to it from config.groovy.
If it's basically a static file, I'd put it in src/java/resources, and load it with something like this.class.getResource("/resources/file.csv") as you would with a regular java app