JAXB 编组/解组 - SWT.Image 或 AWT BufferedImage
我正在尝试使用 jaxb 编组一个包含图像的对象,然后对其进行解组(即保存/加载)。
有没有办法存储该图像?
我正在尝试创建一个返回描述 swt.image 图像数据的字节数组的函数,但是一旦我将其标记为 @XmlElement,存储它的过程就会失败并引发如下异常:
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
JAXB annotation is placed on a method that is not a JAXB property
this problem is related to the following location:
at @javax.xml.bind.annotation.XmlElement()
另外,我已经测试了转换 SWT .Image 到 AWT.BufferedImage,但我仍然得到相同的异常。
I am trying to marshal with jaxb an object which contains an Image, and afterwards unmarshalling it (i.e. save/load).
Is there a way to store that image?
I am trying to create a function which returns the byte array describing the swt.image imagedata, but once I marked it as an @XmlElement, the process of storing it fails throwing an Exception like this:
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
JAXB annotation is placed on a method that is not a JAXB property
this problem is related to the following location:
at @javax.xml.bind.annotation.XmlElement()
Also, I have tested to convert the SWT.Image to a AWT.BufferedImage, but I still get the same Exception.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的异常表明您已在不是访问器的方法(get/set 方法)上放置了注释。下面是使用
java.awt.Image
属性的示例:Root
Demo
Output
Your exception indicates that you have placed an annotation on a method that isn't an accessor (get/set method). Below is an example using a
java.awt.Image
property:Root
Demo
Output