You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Josh Reagan (Jira)" <ji...@apache.org> on 2024/04/10 18:55:00 UTC
[jira] [Created] (CAMEL-20664) camel-mapstruct - MapStruct mappers not found in Spring Boot
Josh Reagan created CAMEL-20664:
-----------------------------------
Summary: camel-mapstruct - MapStruct mappers not found in Spring Boot
Key: CAMEL-20664
URL: https://issues.apache.org/jira/browse/CAMEL-20664
Project: Camel
Issue Type: Bug
Components: camel-mapstruct
Affects Versions: 4.0.0
Environment: $ java -version
openjdk version "17.0.7" 2023-04-18
OpenJDK Runtime Environment Temurin-17.0.7+7 (build 17.0.7+7)
OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode, sharing)
Reporter: Josh Reagan
Attachments: camel-mapstruct-demo.zip
The `DefaultMapStructFinder` is unable to locate the `Mapper` classes when running in Spring Boot. Seems to throw an exception calling `PluginHelper.getPackageScanClassResolver(ecc).findByFilter(f -> f.getName().endsWith("Mapper"), names);` inside the `doInit()` method.
You can work around this by creating your own `MapStructFinder`, extending `DefaultMapStructFinder`, overriding the `doInit()` function, and calling `discoverMappings(...)` with each of your `Mapper` classes. That way it doesn't try to scan the classpath to find the `Mapper` classes automatically. I've attached a working example to illustrate.
*Note: It has no issue locating them when running `mvn spring-boot:run`. Only when running from the packaged uber jar with `java -jar ...`.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)