Play框架中的Yml文件:它们可以相互引用吗
在我的应用程序中,我想用大数据来初始化它。当我将所有这些数据写入一个 YML 文件时,它大约为 4 MB,但应用程序并没有开始出现 java 堆空间错误。当我删除其中的某些部分直到 109 KB 时,一切正常,但当然有一些丢失的数据。
我对解决这个问题的期望是以下之一:
- 制作多个文件,但是如何引用另一个YML文件中的对象,这可能吗?
- 在启动时通过代码将模式加载到数据库中,这容易做吗?
- 此问题读者提出的解决方案...
注意:我的应用程序中的大部分数据都是相互引用的,因此我无法将它们完全分开在多个文件中。
In my application, I want to initialize it with large data. when I wrote all these data in one YML file it was about 4 MB but then the application didn't start making a java heap space error. when I remove some parts of it till 109 KB, everything works but of course with some missing data.
My expectation to solve this problem is one of the following:
- make more than one file, But how to refer to an object in another YML file, is this possible?
- Load a schema into the database via code at start up, is this easy to make?
- a solution proposed by any of this question readers ...
Note: most of the data in my application refers to each other so I couldn't separate them in more than one file totally.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(2)
傲影2024-12-12 05:55:47
我在创业工作中做了类似的事情:
@Override
public void doJob() {
if (Image.count() == 0 && Play.mode.equals(Play.Mode.DEV)) {
Fixtures.deleteAllModels();
List<Image> images = Fixtures.loadYaml("Images.yml", List.class); //<-- this just loads the image objects (not in db yet)
Fixtures.loadModels("Albums.yml"); // <----- this puts albums into db
int i = 0;
for (Image img : images) {
img.album = Album.find("byName", img.album.name).first();
img.save(); // <--- here image entities go into db
i++;
}
}
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您可以查看 DBUnit 来转储并重新加载整个数据库,假设它是 SQL。
You could look at DBUnit to dump and reload your whole DB, assuming it's SQL.