After upgrading to Spring Boot 2.6.3, a BeanCurrentlyInCreationException may occur. This is triggered when two mappers reference each other and thus form a circle
@Mapper( componentModel = "spring", uses = { FooMapper.class })
public interface BarMapper {
Bar toBo(BarDto dto);
BarDto toDto(Bar obj) ;
}
@Mapper( componentModel = "spring", uses = { BarMapper.class })
public interface ForMapper {
Foo toBo(FooDto dto);
FooDto toDto(Foo obj) ;
}
Circle detection is a change from Spring Boot 2.6 (Release Notes). Currently there is also a possibility to work around the problem by setting spring.main.allow-circular-references=true.
A better way would be to work around the problem using @Lazy Annotation. Is it possible to extend the SpringComponentProcessor to enable @Lazy autowire support?
example.zip