JAXB - generated classes implement interface

僤鯓⒐⒋嵵緔 提交于 2019-12-09 15:41:53

问题


Is there a way to configure JAXB to so that a generated class implements a specified interface? I'm intending to use JAXB generated classes as DAO's and they should be able implement my DAO interface.


回答1:


The interface injection plugin for XJC lets you do this.




回答2:


Unfortunately, it looks like the interface-injection plugin mentioned in some of the other answers is no longer well supported. In fact, I'm having trouble finding the JAR for download.

Thankfully, the JAXB2 Basics Plugins provides a similar mechanism for adding an interface to the generated JAXB stubs (see the Inheritance plugin).

The JAXB2 Basics Plugins documentation includes instructions for using the plugin with Ant and Maven.

The JAXB2 Basics Plugins provides a number of other utilities which you might also find useful (such as autogeneration of equals, hashCode, and toString methods).



来源:https://stackoverflow.com/questions/2916217/jaxb-generated-classes-implement-interface

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!