简体   繁体   English

使用DOZER映射而不设置方法

[英]Mapping with DOZER without method set

I am trying to convert two classes that have an attribute of type java.util.List, but one of the classes does not have a method "set*" only the method "get*" like this: 我正在尝试转换两个属性类型为java.util.List的类,但是其中一个类没有方法“ set *”,只有方法“ get *”是这样的:

<mapping>
        <class-a>com.mycompany.bean.SocioPj</class-a>
        <class-b>com.mycompany.jaxb.SocioPjXml</class-b>
        <field>
            <a set-method="getListaSocios().add">listaSocios</a>
            <b>listaSocios</b>
            <a-hint>com.mycompany.bean.SocioPf,com.mycompany.bean.SocioPj</a-hint>
            <b-hint>com.mycompany.jaxb.SocioPfXml,com.mycompany.jaxb.SocioPjXml</b-hint>
        </field>
    </mapping>

The example above the class: SocioPj doesn´t have a method setListSocios() when I tried to convert I catch this error: 类上方的示例:当我尝试进行转换时,SocioPj没有方法setListSocios()时发现此错误:

[Time:2015-03-24 11:29:08,055][Level:ERROR][Thread:http-bio-8080-exec-10][OnboardingCCMFulfillmentImpl] org.dozer.MappingException: java.lang.ClassNotFoundException: /add

Has anyone faced this problem? 有人遇到过这个问题吗?

You can tell Dozer to directly access the field without calling the getter/setter (Even if the field is private ): 您可以告诉Dozer无需调用getter / setter即可直接访问该字段(即使该字段是private ):

<field>
    <a is-accessible="true">listaSocios</a>
    <b>listaSocios</b>
</field>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM