2

我正在尝试使用 spring(@Autowire注释到 Jaxb Model 类中)

.....

@XmlAttribute(name = "object-id")
@XmlSchemaType(name = "positiveInteger")
protected BigInteger objectId;

@XmlTransient
@Autowired MediationCacheManager cacheManager;

MediationCacheManager从三个接口扩展在哪里

在创建 JaxbContext 时,我捕获了一个异常: Exception [EclipseLink-50089] (Eclipse Persistence Services - 2.5.0.v20121116-8650760): org.eclipse.persistence.exceptions.JAXBException Exception Description: The java interface com.netcracker.mediation.common.caches.api.MediationCacheManager can not be mapped by JAXB as it has multiple mappable parent interfaces. Multiple inheritence is not supported

当然,我知道 eclipselink 不支持多重继承,但是如何cacheManager从 Jaxb 处理中跳过字段?至于我 - 它应该通过XmlTransient注释来完成,但它不起作用。你有什么想法吗?

4

1 回答 1

2

您看到的问题对应于我们在 EclipseLink 2.5.1 和 2.6.0 流中修复的错误 ( http://bugs.eclipse.org/411993 )。从 2013 年 7 月 4 日开始,您可以从以下链接下载每晚构建:


解决方法

您可以使用 MOXy 的外部映射文档来覆盖超类型MediationCacheManager以使您的用例工作(请参阅:http ://blog.bdoughan.com/2010/12/extending-jaxb-representing-annotations.html ):

oxm.xml

<?xml version="1.0"?>
<xml-bindings
    xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
    package-name="forum17458822">
    <java-types>
        <java-type name="MediationCacheManager" super-type="java.lang.Object"/>
    </java-types>
</xml-bindings>

演示

import java.util.*;
import javax.xml.bind.JAXBContext;
import org.eclipse.persistence.jaxb.JAXBContextProperties;

public class Demo {

    public static void main(String[] args) throws Exception {
        Map<String, Object> properties = new HashMap<String, Object>(1);
        properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, "forum17458822/oxm.xml");
        JAXBContext jc = JAXBContext.newInstance(new Class[] {Foo.class}, properties);
    }

}
于 2013-07-04T09:14:23.907 回答