第一个报错
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. [ERROR][org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter:40] - *************************** APPLICATION FAILED TO START *************************** Description: A component required a bean of type 'com.xxx.xxx.convert.SubNoticeConvertor' that could not be found. Action: Consider defining a bean of type 'com.xxx.xxx.convert.SubNoticeConvertor' in your configuration.
那么我就把@Mapper(componentModel = "spring") 替换为@Mapper后利用Mappers.getMapper的方式还是不行。
2、这下换了另外的报错,Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: Cannot find implementation for com.xxx.xxx.convert.SubNoticeConvertor at org.mapstruct.factory.Mappers.getMapper(Mappers.java:61) ~[mapstruct-1.5.3.Final.jar:?] at com.
后边一顿操作引入maven
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.5.3.Final</version>
</annotationProcessorPath>
<!-- Lombok 注解处理器 -->
<!-- <annotationProcessorPath>-->
<!-- <groupId>org.projectlombok</groupId>-->
<!-- <artifactId>lombok</artifactId>-->
<!-- <version>1.18.24</version> <!– 使用稳定版 –>-->
<!-- </annotationProcessorPath>-->
</annotationProcessorPaths>
</configuration>
</plugin>
oh no!还是不可以!
好吧。。。查看idea的设置,发现也是正常的
一次次maven clean,一次次重启服务,转换类的实现方法一直没有编译成功!陷入自闭。。。
最后说一下奇葩解决方法:
idea清理缓存
File-Invalidate Caches
看到的都勾选并清理重启idea
重启后,maven clean一下后,启动项目正常能转换。Spring注入的方式和INSTANCE方式都可以正常转换,并且去除了之前添加的plugin后也可以正常转换对象