我正在尝试使用java将DO转换为DTO,并在开始编写自己的工具之前寻找自动化工具。我只是想知道是否有同样的免费工具可用。
当前回答
还有一个Java映射引擎/框架Nomin: http://nomin.sourceforge.net。
其他回答
你可以试试Dozer。
Dozer是一个Java Bean到Java Bean的程序 递归复制数据的映射器 从一个物体到另一个物体。通常情况下, 这些Java bean将是不同的 复杂类型。 Dozer支持简单属性 映射,复杂类型映射, 双向映射, 隐式-显式映射,以及 递归的映射。这包括 映射集合属性 还需要在元素处进行映射 的水平。
使用Apache commons beanutils:
静态无效copyProperties(对象dest,对象origin) -将所有属性值从源bean复制到目标bean 属性名为的情况 相同。
http://commons.apache.org/proper/commons-beanutils/
我建议您试试JMapper框架。
它是一个Java bean到Java bean的映射器,允许您使用注释和/或XML动态地执行数据传递。
使用JMapper你可以:
创建并充实目标对象 对映射应用特定的逻辑 自动管理XML文件 实现1到N和N到1的关系 实现显式转换 应用继承的配置
另一个是Orika - https://github.com/orika-mapper/orika
Orika is a Java Bean mapping framework that recursively copies (among other capabilities) data from one object to another. It can be very useful when developing multi-layered applications. Orika focuses on automating as much as possible, while providing customization through configuration and extension where needed. Orika enables the developer to : Map complex and deeply structured objects "Flatten" or "Expand" objects by mapping nested properties to top-level properties, and vice versa Create mappers on-the-fly, and apply customizations to control some or all of the mapping Create converters for complete control over the mapping of a specific set of objects anywhere in the object graph--by type, or even by specific property name Handle proxies or enhanced objects (like those of Hibernate, or the various mock frameworks) Apply bi-directional mapping with one configuration Map to instances of an appropriate concrete class for a target abstract class or interface Handle reverse mappings Handle complex conventions beyond JavaBean specs. Orika uses byte code generation to create fast mappers with minimal overhead.
我很高兴添加Moo作为一个选项,尽管很明显我对它有偏见: http://geoffreywiseman.github.com/Moo/
它在简单的情况下很容易使用,在更复杂的情况下也很有能力,尽管我仍然可以想象在一些方面对它进行进一步的改进,以解决更复杂的问题。
推荐文章
- 在maven中安装mvn到底做什么
- 不可变与不可修改的集合
- 如何在JSON中使用杰克逊更改字段名
- GSON -日期格式
- 如何从线程捕获异常
- 无法解析主机"<URL here>"没有与主机名关联的地址
- 如何在Java中打印二叉树图?
- String.format()在Java中格式化双重格式
- com.jcraft.jsch.JSchException: UnknownHostKey
- Java中的操作符重载
- 如何加速gwt编译器?
- 在Hibernate中重新连接分离对象的正确方法是什么?
- 应该……接住环内还是环外?
- 如何格式化Joda-Time DateTime仅为mm/dd/yyyy?
- 如何在POM.xml中引用环境变量?