How to use JAXB annotations in the client side for GWT?

后端 未结 5 1667
孤独总比滥情好
孤独总比滥情好 2020-12-28 18:09

I wanted to use the JaxB annotation in my class like this:

@XmlRootElement
public class ItemExtension implements Serializable {

But GWT com

相关标签:
5条回答
  • 2020-12-28 18:36

    I was able to solve my GWT compiler issues by excluding the generated JAXB ObjectFactory from the source in the GWT module XML:

    <source path="model">
        <exclude name="**/ObjectFactory.*" />
    </source>
    
    0 讨论(0)
  • 2020-12-28 18:37

    I have used this library to do jaxb parsing from within a GWT client

    http://code.google.com/p/gwtjaxb/

    It is not a full JAXB generator, but it covers everything that I need.

    0 讨论(0)
  • 2020-12-28 18:40

    You might find a viable solution here: GWT with JPA

    0 讨论(0)
  • 2020-12-28 18:46

    I have a project that uses entity classes with both JPA and JAXB annotations in the client-side GWT code. See the section "Overriding one package implementation with another" in the GWT Documentation.

    Let's say your module is in package com.example.app. You will need to recreate[1] all JAXB annotation classes in a new package, specifically com.example.app.jre.java.xml.bind.annotation; in your module XML file, you then add <super-source path="jre" /> and you're set.

    Note that you don't need to distribute the class files in that package, they are needed solely for the sake of the GWT compiler.

    [1]: You can copy them over and adjust all package references.

    0 讨论(0)
  • 2020-12-28 18:54

    Have you checked these discussions already:

    http://groups.google.com/group/google-web-toolkit/browse_thread/thread/849c6cc6c9b1467a/cab6b973bbf7d162?hl=en&lnk=gst&q=jaxb+annotations#cab6b973bbf7d162

    and

    http://groups.google.com/group/google-web-toolkit/browse_thread/thread/6312cedd281b91a9/b1add5932c842ace?hl=en&lnk=gst&q=jaxb+annotations#b1add5932c842ace

    0 讨论(0)
提交回复
热议问题