本文介绍了Quick'n'dirty持久性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我经常发现自己需要快速(在代码方面),轻量级(在运行时,依赖性方面)持久性解决方案,只需要一堆对象,主要是在应用程序重启之间。I often find myself needing a quick ( in terms of code ), lightweight ( in term of runtime, dependencies) persistence solution for simply a bunch of objects, mainly between application restarts.通常我会使用一些Java序列化黑客,但我想知道是否有更好的东西。Usually I resort to some Java serialisation hack, but I wonder if there's something better out there.您是否使用过类似的东西?Have you used something similar?为了说清楚,我的书中基于JPA的解决方案不是轻量级,而且是基于JDBC的一个不快。To make it clear, a JPA-based solution is not lightweight in my book, and a JDBC-based one is not quick. 更新:我赞成配置 - 那些需要配置的框架。例如,Java序列化解决方案需要实现Serializable 并且它可以工作。带注释或带有映射文件的JPA解决方案太重了。Update: I favour configuration-less frameworks over those which require configuration. For instance the Java serialisation solution requires a implements Serializable and it works. A JPA solution, either with annotations or with mapping files would be too heavyweight. 更新2 :为了说清楚,我不知道认为序列化是一个黑客。它实际上是一个非常强大的机制,只是我在执行持久性时以一种hackish方式使用它。Update 2: Just to make it clear, I don't think Serialisation is a hack. It's actually a very powerful mechanism, just that I'm using it in a hackish way when doing persistence.推荐答案我更喜欢 XStream :只需要一个Jar,快速且易于使用I prefer XStream: Only one Jar needed, fast and very easy to use 这篇关于Quick'n'dirty持久性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-30 02:28