2012-07-13 18 views
4

使用莫西我可以打平我的对象模型的零件在我的JSON输出你怎么莫西OXML映​​射文件来识别静态类

<java-type name="Medium"> 
    <java-attributes> 
    <xml-element java-attribute="trackList" xml-path="."/> 
    </java-attributes> 
</java-type> 

但是当我想折叠类这是一个静态类的儿童如下

<java-type name="Medium.TrackList"> 
    <java-attributes> 
    <xml-element java-attribute="artistList" xml-path="."/> 
    </java-attributes> 
</java-type> 

它抱怨

Exception Description: Could not load class [Medium.TrackList] declared in the external metadata file. Please ensure that the class name is correct, and that the correct ClassLoader has been set. 
    at org.eclipse.persistence.exceptions.JAXBException.couldNotLoadClassFromMetadata(JAXBException.java:376) 
    at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.getXmlBindingsClasses(JAXBContext.java:979) 
    at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:879) 
    at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:157) 

我该如何解决?

回答

3

当在OXM中指定内部类时,EclipseLink实际上需要“$”分隔符。我复制了你的问题,并通过在你的oxm文件中改变它来修复它。

<java-type name="Medium$TrackList"> 
    <java-attributes> 
    <xml-element java-attribute="artistList" xml-path="."/> 
    </java-attributes> 
</java-type> 

希望这有助于

里克

+1

三江源这是问题 – 2012-07-16 11:43:18