栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

从模式向JAXB绑定类添加注释

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

从模式向JAXB绑定类添加注释

问题解决了。

JAXB插件Annotate
http://confluence.highsource.org/display/J2B/Annotate+Plugin完成了这项工作。

在您的jaxb绑定文件(外部绑定,即.xjb文件)中添加以下片段:

<jaxb:bindings schemaLocation="csw/2.0.2/CSW-discovery.xsd" node="/xs:schema">  <jaxb:bindings node="xs:complexType[@name='GetRecordsType']">    <annox:annotate>  <annox:annotate annox:      name="GetRecordsType" /></annox:annotate>  </jaxb:bindings></jaxb:bindings>

不要忘记声明名称空间:

<jaxb:bindings   xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"  xmlns:xs="http://www.w3.org/2001/XMLSchema"   xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xmlns:annox="http://annox.dev.java.net"  xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"  jaxb:extensionBindingPrefixes="xjc annox" version="2.1"> ... </jaxb:bindings>

并使用ANT或MAVEN任务http://confluence.highsource.org/display/J2B/User+Guide进行源代码的生成。

我仍在搜索如何手动指定JAXB扩展名(不使用ant或maven进行xjc任务),但现在可以使用。(我有自己的ANT脚本,这就是为什么我搜索手动调用XJC的原因)。

JAXB扩展机制非常方便,请参阅JAXB2基础:http
://confluence.highsource.org/display/J2B/Home




转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/494835.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号