modelmapper

NullPointerException when trying to define a custom PropertyMap

女生的网名这么多〃 提交于 2019-11-29 14:55:28
I'm using ModelMapper the following way : I have a few converter classes that are Spring components and they register custom ModelMapper mappings @Component public class FooConverter { @Autowired private ModelMapper modelMapper; public static final PropertyMap<Foo, FooModel> FOO_TO_FOO_MODEL_MAP = new PropertyMap<Foo, FooModel>() { @Override protected void configure() { map().setTimeZone(source.getTimeZone().getID()); } }; @PostConstruct public void init() { modelMapper.addMappings(FOO_TO_FOO_MODEL_MAP); } } But I get the following error when Spring starts because the configure function gets

How to use Explicit Map with Java 8 and ModelMapper?

心已入冬 提交于 2019-11-29 07:16:23
问题 I learn how to use ModelMapper by official documentation http://modelmapper.org/getting-started/ There is code sample for explicit mapping using java 8 modelMapper.addMappings(mapper -> { mapper.map(src -> src.getBillingAddress().getStreet(), Destination::setBillingStreet); mapper.map(src -> src.getBillingAddress().getCity(), Destination::setBillingCity); }); How to use this code correctly? When I type this code snippet in IDE, IDE show me message cannot resolve method map 回答1: They missed a

NullPointerException when trying to define a custom PropertyMap

半世苍凉 提交于 2019-11-28 09:06:42
问题 I'm using ModelMapper the following way : I have a few converter classes that are Spring components and they register custom ModelMapper mappings @Component public class FooConverter { @Autowired private ModelMapper modelMapper; public static final PropertyMap<Foo, FooModel> FOO_TO_FOO_MODEL_MAP = new PropertyMap<Foo, FooModel>() { @Override protected void configure() { map().setTimeZone(source.getTimeZone().getID()); } }; @PostConstruct public void init() { modelMapper.addMappings(FOO_TO_FOO