Thursday, June 7, 2012

Generate XmlRootElement for jaxb objects

I recently had to add XmlRootElement to a class. After using google for a while, I finally figured out a way to do it. I Updated the pom jaxb plugin to include the annotate plugin and created a mappings file that customizes the jaxb object. pom.xml:
<plugin>
    <groupid>org.jvnet.jaxb2.maven2</groupid>
    <artifactid>maven-jaxb2-plugin</artifactid>
    <configuration>
        <extension>true</extension>
        <strict>false</strict>
        <plugins>
            <plugin>
                <groupid>org/jvnet/jaxb2_commons</groupid>
                <artifactid>annotate</artifactid>
                <version>0.4.1.5</version>
            </plugin>
        </plugins>
    </configuration>
    <executions>
        <execution>
            <id>generate</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <bindingincludes>
                    <include>*.xjb</include>
                </bindingincludes>
                <args>
                    <arg>-Xannotate</arg>
                </args>            
            </configuration>
        </execution>
    </executions>
</plugin>
file.xjb:
<!--?xml version="1.0" encoding="UTF-8" standalone="yes"?-->
<jaxb:bindings version="2.1"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:annox="http://annox.dev.java.net"
jaxb:extensionbindingprefixes="annox">
    <jaxb:bindings schemalocation="filename.xsd" node="/xs:schema">
        <jaxb:bindings node="xs:complexType[@name='ObjectType']">
            <annox:annotate>
                <annox:annotate 
                annox:class="javax.xml.bind.annotation.XmlRootElement"
                name="access">
            </annox:annotate>
        </annox:annotate></jaxb:bindings>
    </jaxb:bindings>
</jaxb:bindings>

10 comments:

Bangalore Training Academy said...

Really very happy to say, your post is very interesting to read. I never stop myself to say something about it. You’re doing a great job. Keep it up...

Tableau Training in Bangalore
Tableau Courses in Bangalore
Tableau Classes in Bangalore
Tableau Training Institute in Bangalore
Tableau Course Syllabus
Best Tableau Training
Tableau Training Centers

Bangalore Training Academy said...

I think this is one of the most significant information for me. And I’m glad reading your article. Thanks for sharing!

Data Science Training in Bangalore
Data Science Courses in Bangalore
Data Science Classes in Bangalore
Data Science Training Institute in Bangalore
Data Science Course Syllabus
Best Data Science Training
Data Science Training Centers

Bangalore Training Academy said...

Very interesting, good job and thanks for sharing such a good blog. Thanks a lot…
Workday Training in Bangalore
Workday Courses in Bangalore
Workday Classes in Bangalore
Workday Training Institute in Bangalore
Workday Course Syllabus
Best Workday Training
Workday Training Centers

Anu said...

I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post I would like to read this
DevOps Training | Certification in Chennai | DevOps Training | Certification in anna nagar | DevOps Training | Certification in omr | DevOps Training | Certification in porur | DevOps Training | Certification in tambaram | DevOps Training | Certification in velachery

Revathi said...

Good post!Thank you so much for sharing this lovely article.It was so good to read and useful to upgrade my understanding...keep on share!!!

android training in chennai

android online training in chennai

android training in bangalore

android training in hyderabad

android Training in coimbatore

android training

android online training

praveen said...

First i got a great blog .I will be interested in more similar topics. i see you got really very useful topics, i will be always checking your blog thanks.
sap training in chennai

sap training in porur

azure training in chennai

azure training in porur

cyber security course in chennai

cyber security course in porur

ethical hacking course in chennai

ethical hacking course in porur

jeni said...


A universal message I suppose, not giving up is the formula for success I think. Some things take longer than others to accomplish, so people must understand that they should have their eyes on the goal, and that should keep them motivated to see it out til the end.


Selenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune
Selenium Online training

Anonymous said...

betpoint vip club - stillcasino.com
It was first time it had been possible to 카지노사이트 bet matchpoint with live betting 카지노 in the Bet365.com casino. Bet365 is also one of the more reputable online bookmakers in the

tech said...

Best Encryption Software for Mac in 2022 ; FoneDog · User-friendly; Free download version; Auto-lock setup; Uses the safest encryption .How To Encrypt Files On Mac

haseeb said...

Welcome Back to Work | Wishes for the First Working Day after Holidays · Since work has to be done after a relaxing holiday, here are some beautiful wishes that .Welcome Back Message To Boss