Reputation: 2084
I get the following error on application deployment in Tomcat 9 when using MapStruct, Lombock and Spring:
No qualifying bean of type 'somepackage.ControllerBusinessMapper' available: expected at least 1 bean which qualifies as autowire candidate
This is my pom.xml:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>[1.18.12,)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>1.3.1.Final</version>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.3.1.Final</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
This is the mapper:
@Mapper(componentModel = "spring")
public interface ControllerBusinessMapper {
//Some methods
}
And in the class where its injected:
@Autowired
private ControllerBusinessMapper businessMapper;
My spring configuration class sets the package scan in the root of the package hierarchy. And also the implementation of the mapper is generated under target/generated-sources:
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2020-08-23T03:56:23+0200",
comments = "version: 1.3.1.Final, compiler: javac, environment: Java 11.0.7 (Oracle Corporation)"
)
@Component
public class ControllerBusinessMapperImpl implements ControllerBusinessMapper {
//Some methods
}
The error I have suggests Spring is not able to find the implementation class, what am I missing? I tried to add the generated-sources folder to the build path and include it in the package scan but it didnt work.
Upvotes: 0
Views: 1330
Reputation: 2084
Additional configuration in Eclipse is needed in order to use MapStruct:
Upvotes: 1