我正在尝试使用Eclipse从Java类生成XSD。 我的领域就是这样。
private Map<EnumType1, SortedSet<JavaClass2>> choices;
我也有如下的吸气剂方法。这是示例代码,与实际代码有所不同,但显示了意图。
public Map<EnumType1, SortedSet<JavaClass2>> getChoices() {
return choices;
}
Jaxb引发错误
我认为JAXB不会为其中具有嵌套集合的字段生成xml模式。这种领域的解决方案是什么?
我在吸气剂上添加了@XmlTransient标记以避免发生异常,并生成了不包含这些类型的字段的架构。
此模式的更多字段引发异常,如下所示-示例代码
public Map<Long, Map<String, String>> getMyMap() {
return null;
}
错误消息是这样的
com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts
of IllegalAnnotationExceptions
java.util.SortedSet is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at java.util.SortedSet
截断的异常
at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:106)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:471)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:303)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:139)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1156)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:165)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:441)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
at org.eclipse.jpt.jaxb.core.schemagen.Main.buildJaxbContext(Main.java:99)
at org.eclipse.jpt.jaxb.core.schemagen.Main.generate(Main.java:78)
at org.eclipse.jpt.jaxb.core.schemagen.Main.execute(Main.java:64)
at org.eclipse.jpt.jaxb.core.schemagen.Main.main(Main.java:49)`