【发布时间】:2020-07-23 08:41:53
【问题描述】:
我有一个带有 lombok 和 mapstruct 并使用 maven 作为构建工具的 spring boot 项目。我需要在编译时处理注释,生成的源与最终的 jar 一起打包。构建成功。但是,最终的 jar 缺少 mapstruct 实现类。我尝试启动spring boot应用程序时的错误是:
应用程序启动失败
说明:
字段 salesforceObjectMapper 在 com.some_org.service.salesforce.object.processor.SalesforceObjectProcessor 需要一个 bean 类型 'com.some_org.service.salesforce.object.mapper.SalesforceObjectMapper' 找不到。
行动:
考虑定义一个 bean 类型 'com.some_org.service.salesforce.object.mapper.SalesforceObjectMapper' 在您的配置中。
这是我的 maven-compiler-plugin 设置:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.2.0.Final</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<compilerArg>-Amapstruct.suppressGeneratorTimestamp=true</compilerArg>
<compilerArg>-Amapstruct.suppressGeneratorVersionInfoComment=true</compilerArg>
</compilerArgs>
</configuration>
</plugin>
【问题讨论】:
标签: java spring-boot maven lombok mapstruct