我正在尝试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.
更多推荐
发布评论