Repository navigation
Mapstruct generated class only contains the compile error information. #3812
Replies: 4 comments 4 replies
|
Hi @liudongqing Can you provide a github project with a reproducer? Haven't seen something like this before. Thanks in advance! |
|
I also have this problem,But it appears randomly.In my case,i found the "target/generated-sources" directory have the right mapstrcut mapper interface implement ,but the classes directory xxxMapperImpl.class show compile errors like below: @Component
public class SentenceVariantMapperImpl {
public SentenceVariantMapperImpl() {
throw new Error("Unresolved compilation problems: \n\tThe import com.englishlearning.application.content.dto.SentenceVariantDTO cannot be resolved\n\tSentenceVariantMapper cannot be resolved to a type\n\tSentenceVariantDTO cannot be resolved to a type\n\tThe method toDTO(SentenceVariant) of type SentenceVariantMapperImpl must override or implement a supertype method\n\tSentenceVariantDTO cannot be resolved to a type\n\tSentenceVariantDTO cannot be resolved\n\tSentenceVariantDTO cannot be resolved to a type\n\tSentenceVariantDTO cannot be resolved to a type\n\tThe method toDTOList(List<SentenceVariant>) of type SentenceVariantMapperImpl must override or implement a supertype method\n\tSentenceVariantDTO cannot be resolved to a type\n\tSentenceVariantDTO cannot be resolved to a type\n\tThe method toDTO(SentenceVariant) from the type SentenceVariantMapperImpl refers to the missing type SentenceVariantDTO\n\tThe method toEntityList(List<SentenceVariantDTO>) of type SentenceVariantMapperImpl must override or implement a supertype method\n\tSentenceVariantDTO cannot be resolved to a type\n\tSentenceVariantDTO cannot be resolved to a type\n");
}
public SentenceVariantDTO toDTO(SentenceVariant entity) {
throw new Error("Unresolved compilation problems: \n\tSentenceVariantDTO cannot be resolved to a type\n\tThe method toDTO(SentenceVariant) of type SentenceVariantMapperImpl must override or implement a supertype method\n\tSentenceVariantDTO cannot be resolved to a type\n\tSentenceVariantDTO cannot be resolved\n");
}
public SentenceVariant toEntity(SentenceVariantDTO dto) {
throw new Error("Unresolved compilation problem: \n\tSentenceVariantDTO cannot be resolved to a type\n");
}
public List<SentenceVariantDTO> toDTOList(List<SentenceVariant> entityList) {
throw new Error("Unresolved compilation problems: \n\tSentenceVariantDTO cannot be resolved to a type\n\tThe method toDTOList(List<SentenceVariant>) of type SentenceVariantMapperImpl must override or implement a supertype method\n\tSentenceVariantDTO cannot be resolved to a type\n\tSentenceVariantDTO cannot be resolved to a type\n\tThe method toDTO(SentenceVariant) from the type SentenceVariantMapperImpl refers to the missing type SentenceVariantDTO\n");
}
public List<SentenceVariant> toEntityList(List<SentenceVariantDTO> dtoList) {
throw new Error("Unresolved compilation problems: \n\tThe method toEntityList(List<SentenceVariantDTO>) of type SentenceVariantMapperImpl must override or implement a supertype method\n\tSentenceVariantDTO cannot be resolved to a type\n\tSentenceVariantDTO cannot be resolved to a type\n");
}
}jdk version: Oracle OpenJDK 17.0.1 |
|
I just found this problem. it took me 4-5Hr for find what happend. |
|
I encounter this problem just now. I solve this by alter the interface java file(swap two import line number), then recompile it, and the problem disappeared. A feature of this problem is, in generated calss file, it says 'import xxx.xxx package can't be resolve' which lack the actural class name in the end. which I don't know why. Unresolved compilation problems:
The import com.example.testProject.dto cannot be resolved
The import com.example.testProject.dto cannot be resolved
The import com.example.testProject.entity cannot be resolved
TCategoryConverter cannot be resolved to a type
TCategoryUpdateDTO cannot be resolved to a type
TCategory cannot be resolved to a type
CategoryCreateDTO cannot be resolved to a type
TCategory cannot be resolved to a type |
Uh oh!
There was an error while loading. Please reload this page.
I have a spring boot project that uses the maven to build. I use the mapstruct in one class. But when I execute
mvn spring-boot:run, it failed with the message: "Caused by: java.lang.Error: Unresolved compilation problems:". It is very strange as themvn compilecommand can succeed. Then I check the compiled mapper class, it only contains an exception statement, like below:Looks like mapstruct genereted a java file only contains the error throw statement?
I am using :
Java : Java(TM) SE Runtime Environment (build 17.0.12+8-LTS-286) from Oracle
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Spring boot: 3.4.1
MapStruct: tried both 1.6.3 and 1.5.5 final
All reactions