Using JDK's JAXB without ns2 prefix

后端 未结 2 1279
伪装坚强ぢ
伪装坚强ぢ 2021-02-08 05:50

After having read all posts about this on Oracle forums, Stackoverflow, java.net I\'m finally posting here. I\'m using JAXB to create XML files but the problem is that it adds t

2条回答
  •  一整个雨季
    2021-02-08 06:37

    I had the same problem today. The production machine has Java 6 and when I deployed my application, I was getting the ns2 prefix. This is how I resolved it. Production server has only Java 1.6 patch 21

    1. I made sure that I have a package-info.java file in my package where all the classes were generated using Jaxb. I checked it and the @XmlSchema was all auto generated, so I didn't mess with any of that. Don't use namespacemapper, that just confused me.

    2. In my pom.xml file, I added jaxb-impl dependency: com.sun.xml.bind jaxb-impl 2.2.5-b04

      and specified source and target as 1.6. Did a maven clean install and package and deployed into production, everything looks good. Next step is to make sure that production machine is upgraded to Java 7. Hope this helps :)

提交回复
热议问题