在Grails项目中放置资源的位置? [英] Where to place resources in Grails project?

查看:92
本文介绍了在Grails项目中放置资源的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道Grails应用程序中是否有资源文件的指定位置?我有一个csv文件被加载到地图中(没有什么大不了),但不知道把它放到项目中的位置。

所以我的问题是,项目中是否有专门的地方放置这个文件? (如果是这样,在哪里?)或者是最好将它放在项目之外?

解决方案

如果csv将要需要不时更新,我把它放在你的grails文件夹的外部,并从config.groovy指向它。



如果它基本上是一个静态文件,那么我'd将它放在src / java / resources中,并像使用常规java应用程序一样使用this.class.getResource(/ resources / file.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?

解决方案

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

这篇关于在Grails项目中放置资源的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆