Reproduce steps 1. new starter only contain spring-boot-web 2. add mapstruct in pom.xml 3. use org.mapstruct.ap.internal.util.Collections 4. if started by idea/eclipse: it's ok 5. when package to jar. error: java.lang.NoClassDefFoundError: org/mapstruct/ap/internal/util/Collections
java: java21 spring-boot: 3.3.2 err, 2.7.18 err, 2.4.0 err, but SpringBoot2.3.9.RELEASE ok
import org.mapstruct.ap.internal.util.Collections;
@RequestMapping
@RestController
@SpringBootApplication
public class ZzDemo01Application {
public static void main(String[] args) {
SpringApplication.run(ZzDemo01Application.class, args);
}
@GetMapping("hello")
public Set<String> hello() {
return Collections.asSet("a", "b");
}
}
<!--mapstruct start-->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>1.5.5.Final</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.5.5.Final</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.5.5.Final</version>
</dependency>
Comment From: hepengju
I cloned the code, and find from SpringBoot2.4.0: spring-boot-maven-plugin, add new JarTypeFilter exclude it. I will notify to https://github.com/mapstruct/mapstruct
Comment From: hepengju
maybe spring-boot-maven-plugin can give an option: use JarTypeFilter or not and default not.
Comment From: philwebb
The Collections is in an org.mapstruct.ap.internal package so I don't think it's intended to be used in your own code.