Orika必须有公共制定者(Orika must have public setter)

编程入门 行业动态 更新时间:2024-10-27 05:25:30
Orika必须有公共制定者(Orika must have public setter)

我正在尝试Orika,我想知道你是否必须有公共制定者才能使映射工作?

我尝试没有setter,它没有工作,也没有尝试明确告诉byDefault():

factory.classMap(Page.class, PageResource.class).byDefault().register();

对此有何反馈?

I'm trying Orika and I'm wondering if you have to have public setter for the mapping to work ?

I tried without setter, it's not working, neither trying to explicitly tell byDefault() :

factory.classMap(Page.class, PageResource.class).byDefault().register();

any feedback on this one ?

最满意答案

在默认的Orika配置中,映射的对象必须遵循带有getter / setter的JavaBean规范。 另一种可能的方式是拥有公共领域。

要更改此行为,您可以编写自己的PropertyResolverStrategy并对其进行配置。

DefaultMapperFactory build = new DefaultMapperFactory.Builder() .propertyResolverStrategy(new MyCustomPropertyResolvingStrategy()) .build();

有关此主题的更多信息,请参阅文档或orika代码。

In the default Orika configuration, mapped objects have to follow the JavaBean spec with getter/setter. Another possible way is, having public fields.

To change this behavior you can write your own PropertyResolverStrategy and configure it.

DefaultMapperFactory build = new DefaultMapperFactory.Builder() .propertyResolverStrategy(new MyCustomPropertyResolvingStrategy()) .build();

see the documentation or the orika code for more information on this topic.

更多推荐

本文发布于:2023-07-22 10:06:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1219227.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:制定者   Orika   setter   public

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!