CXF发布Rest服务出现错误:javax.xml.bind.JAXBException:以及其任何超类对此上下文都是未知的。
来源:互联网 发布:好玩的竖屏网络哟西 编辑:程序博客网 时间:2024/05/29 10:59
@XmlRootElement(name="User") @XmlAccessorType(XmlAccessType.FIELD) public class User { private String userId; private String userName; // get set 方法省了 } @XmlRootElement(name="Page") @XmlAccessorType(XmlAccessType.FIELD) public class Page { /** * 每页的展现条数 */ private int pageSize = 20; /** * 总记录数 */ private int totalCount; /** * 总页数 */ private int totalPage; /** * 当前页数 */ private int currentPage = 0; /** * 当前页起始记录 */ private int startIndex = 0; /** * 查询结果集 */ @XmlElementWrapper(name="items") // 在集合外包一层,名为items @XmlElement(name="item") // 集合单个元素,名为item private List items; }
这是起初的做法,后台提示“...User 以及其任何超类对此上下文都是未知的”,意思是List中的元素无法转换;
后来继续查找,说是用到@XmlSeeAlso注解,改良为如下,该方案可行,可以转换为json或xml输出。
但是,弊端是,这个分页类就无法通用了,每增加一个类型的分页就要在XmlSeeAlso里增加一个。
- @XmlRootElement(name="PaginationSupport")
- @XmlAccessorType(XmlAccessType.FIELD)
- @XmlSeeAlso({User.class})
- public class PaginationSupportimplements java.io.Serializable{
- 。。。
- }
@XmlRootElement(name="PaginationSupport")@XmlAccessorType(XmlAccessType.FIELD)@XmlSeeAlso({User.class})public class PaginationSupport implements java.io.Serializable{ 。。。}
最后,增加泛型PaginationSupport<T>,也无济于事,不能转换。
请大家帮看看,到底CXF rest的分页如何实现。
- CXF发布Rest服务出现错误:javax.xml.bind.JAXBException:以及其任何超类对此上下文都是未知的。
- cxf 分页查询 以及其任何超类对此上下文都是未知的。
- 错误排查总结-cxf客户端调用报错(任何超类对此上下文都是未知的)
- OSGI环境下的一个错误:javax.xml.bind.JAXBException: ClassCastException
- java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
- java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
- osgi出错java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
- nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
- webservice--CXF发布REST的服务
- Exception in thread “main” javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory
- javax.xml.bind.JAXBException: Unable to locate jaxb.properties for package
- javax.xml.bind.JAXBException: JAXBContextImpl nor any of its super class is known to this context
- webservice--CXF+Spring整合发布REST的服务
- 使用cxf发布rest服务接口,和spring的整合
- 使用CXF和spring发布rest服务
- 调用cxf生成的接口异常修复javax.xml.bind.UnmarshalException - with linked exception
- 关于cxf WebService中错误信息的解决 javax.xml.bind.UnmarshalException
- Apache CXF 的REST 方式发布WebService实现,Android手机后台服务的开发
- 斯坦福机器学习公开课笔记(六)--神经网络的学习
- 从程序员到项目经理(11):每个人都是管理者
- POJ 1195 Mobile phones
- 更新centos默认启动命令版本
- 关于SQL 中的单引号和双引号
- CXF发布Rest服务出现错误:javax.xml.bind.JAXBException:以及其任何超类对此上下文都是未知的。
- 数学之路(3)-数据分析(4)
- 取代top工具的Linux运维利器--htop
- 从程序员到项目经理(12):如何管理自己的时间(上)
- 其实,反射还有另一种功能
- biee登陆界面修改
- SWF to EXE 工具制作
- VS 2005序列号
- JB中切换系统语言后默认输入法会自动切换到latin输入法