如何在服务课上获得豆子?
我正在尝试定义ModelMapper的配置,所有其他类都可以共享。 我创建了一个配置类:
@Configuration
@AllArgsConstructor
public class ModelMapperConfig {
protected final ModelMapper mapper;
@Bean
public ModelMapper getMapper() {
mapper.addMappings(new PropertyMap<MerchantDTO, Merchant>() {
@Override
protected void configure() {
skip(destination.getId());
}
});
return mapper;
}
}
但是当我在另一个服务中使用constructor di时:
private final ModelMapper mapper;
我会发现一个错误
The dependencies of some of the beans in the application context form a cycle:
I'm trying to define a configuration for ModelMapper that can be shared by all other classes.
I created a Configuration class:
@Configuration
@AllArgsConstructor
public class ModelMapperConfig {
protected final ModelMapper mapper;
@Bean
public ModelMapper getMapper() {
mapper.addMappings(new PropertyMap<MerchantDTO, Merchant>() {
@Override
protected void configure() {
skip(destination.getId());
}
});
return mapper;
}
}
but when I use constructor DI in another service:
private final ModelMapper mapper;
I get an error that
The dependencies of some of the beans in the application context form a cycle:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TIS是我们使用的方式:
配置文件:
用于深度映射的配置:
服务:
您可以使用它。
Tis is how we used:
Config file:
Config for deep mapping:
Service:
So you can use it.