XJC超级接口和超类只适用于所有类? [英] XJC superinterface and superclass only for all classes?

查看:181
本文介绍了XJC超级接口和超类只适用于所有类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在一个从xsd文件生成的java类中自动实现一个接口。

I'm trying to automatically implement an interface in one java class generated from a xsd file.

这看起来好像可以做到这一点,但它只会添加对所有类实现SomeInterface ,这是完全愚蠢的。我错过了什么,或者你只能为所有课程做这件事吗?实际上并没有让所有生成的类实现相同的接口。我可以仅将此功能用于一个班级吗?

This looks as if it could do that, but it will only add implements SomeInterface to all classes, which is completly stupid. Am I missing something or can you only do this for all classes? Doesn't really make too much sence to let all generated classes implement the same interface. Can I use this feature for one class only?

推荐答案

你可以使用继承扩展。这适用于特定的类(即 xsd:complexType s)

You could use Inheritance extension provided by JAXB2 Basics Plugins. This works for particular classes (i.e. xsd:complexTypes)

这个问题的答案中也有描述: 生成实现接口的JAXB类

This is also described in answers of this question: Generating a JAXB class that implements an interface

这篇关于XJC超级接口和超类只适用于所有类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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