小编Alf*_*edo的帖子

Mapstruct 1.2.0 未在 springboot 2.0.0.M3 + lombok 中生成映射器类

我正在尝试将以下技术组合在一起的示例项目:

  • 弹簧靴 (2.0.0.M3)
  • 映射结构 (1.2.0.CR1)
  • 龙目岛 (1.16.18)

我已经定义了这个映射器:

@Mapper(componentModel = "spring")
public interface SourceToTargetMapper {

    SourceToTargetMapper MAPPER = Mappers.getMapper( SourceToTargetMapper.class );

    @Mappings({ 
        @Mapping(source = "characteristics", target = "description"),
        @Mapping(source = "identifier", target = "id") 
    })
    public Target toTarget(Source source);
}
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是没有生成实现 SourceToTargetMapper 接口的类。

这是我运行单元测试时得到的跟踪:

2017-09-04 00:13:24.726 ERROR 1712 --- [           main] o.s.test.context.TestContextManager      : Caught exception while allowing TestExecutionListener [org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@568bf312] to prepare test instance [io.alfredux.demo.MapperTest@5ccbeb64]

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'io.alfredux.demo.MapperTest': Unsatisfied dependency expressed through field 'sourceToTargetMapper'; nested exception is …
Run Code Online (Sandbox Code Playgroud)

spring maven lombok spring-boot mapstruct

3
推荐指数
2
解决办法
1万
查看次数

标签 统计

lombok ×1

mapstruct ×1

maven ×1

spring ×1

spring-boot ×1