mapstruct 运行时报了 java.lang.ClassNotFoundException:

解决办法

当前mavan模块必须直接导致mapstruct的jar包,不能通过依赖传递来引用

     <dependency>
                <groupId>org.mapstruct</groupId>
                <artifactId>mapstruct-jdk8</artifactId>
                <version>${org.mapstruct.version}</version>
            </dependency>
            <dependency>
                <groupId>org.mapstruct</groupId>
                <artifactId>mapstruct-processor</artifactId>
                <version>${org.mapstruct.version}</version>
                <scope>provided</scope>
            </dependency>
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: Cannot find implementation for Mapstruc.NodeMapper
	at org.mapstruct.factory.Mappers.getMapper(Mappers.java:61)
	at Mapstruc.NodeMapper.<clinit>(NodeMapper.java:15)
	... 22 more
Caused by: java.lang.ClassNotFoundException: Cannot find implementation for Mapstruc.NodeMapper
	at org.mapstruct.factory.Mappers.getMapper(Mappers.java:75)
	at org.mapstruct.factory.Mappers.getMapper(Mappers.java:58)
	... 23 more

mapstruct 运行时报了 java.lang.ClassNotFoundException:

一般项目都是最外层的parent pom导入mapstruct mavn版本依赖,然后comm模块引入mapstruct 的jar包,service再依赖common中的mapstruct。这样会就会导致这个问题。

上一篇:Non-static method 'delete(java.lang.String, java.lang.String)' cannot be referenced from a


下一篇:Databinding:setTag(java.lang.Object)‘ on a null object reference 问题处理。