maven pom.xml配置

<!-- lombok -->
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.16.8</version>
</dependency>
<dependency>
    <groupId>org.mapstruct</groupId>
    <artifactId>mapstruct-jdk8</artifactId>
    <version>1.2.0.Final</version>
</dependency>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.6.0</version>
    <configuration>
        <annotationProcessorPaths>
            <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${lombok.version}</version>
            </path>
            <path>
                <groupId>org.mapstruct</groupId>
                <artifactId>mapstruct-processor</artifactId>
                <version>${org.mapstruct.version}</version>
            </path>
        </annotationProcessorPaths>
    </configuration>
</plugin>

注意:maven-comiler-plugin插件版本一定要在3.6.0以上,若版本低,则会报找不到属性的错误

如果项目中用到swagger需要在有依赖swagger的地方:

<exclusions>
    <exclusion>
        <artifactId>mapstruct</artifactId>
        <groupId>org.mapstruct</groupId>
    </exclusion>
</exclusions>
否则会报:

Couldn’t retrieve @Mapper annotation

mapstruct lombok结合使用mapstruct lombok结合使用

调用:

AuthMapper.instance.toAuthDto(form);


相关文章:

  • 2021-11-03
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2021-06-03
  • 2021-10-31
  • 2021-07-12
  • 2021-10-07
猜你喜欢
  • 2021-09-26
  • 2022-12-23
  • 2021-11-15
  • 2021-05-21
  • 2021-08-21
  • 2021-06-03
相关资源
相似解决方案