linpeilie / mapstruct-plus

MapStruct Plus is an enhancement to the MapStruct framework. It can automatically generate the transformation operation between two classes through an annotation, omitting the operation of defining the interface of MapStruct, makes Java type conversion easy and elegant.
https://mapstruct.plus/
Apache License 2.0
264 stars 20 forks source link

内部类无法转换,编译无法通过 #49

Closed GIT-GAZZ closed 9 months ago

GIT-GAZZ commented 11 months ago

java: java.lang.NullPointerException: Cannot invoke "javax.lang.model.element.TypeElement.getAnnotationMirrors()" because "targetElement" is null at io.github.linpeilie.processor.generator.AutoMapperGenerator.classIsImmutable(AutoMapperGenerator.java:94) at io.github.linpeilie.processor.generator.AutoMapperGenerator.createTypeSpec(AutoMapperGenerator.java:68) at io.github.linpeilie.processor.generator.AutoMapperGenerator.write(AutoMapperGenerator.java:39) at io.github.linpeilie.processor.AutoMapperProcessor.writeAutoMapperClassFile(AutoMapperProcessor.java:556) at io.github.linpeilie.processor.AutoMapperProcessor.lambda$generateMapper$7(AutoMapperProcessor.java:516) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at io.github.linpeilie.processor.AutoMapperProcessor.generateMapper(AutoMapperProcessor.java:512) at io.github.linpeilie.processor.AutoMapperProcessor.doProcess(AutoMapperProcessor.java:225) at io.github.linpeilie.processor.AutoMapperProcessor.process(AutoMapperProcessor.java:169) at org.jetbrains.jps.javac.APIWrappers$ProcessorWrapper.process(APIWrappers.java:206) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.jetbrains.jps.javac.APIWrappers$1.invoke(APIWrappers.java:362) at jdk.proxy2/io.github.linpeilie.processor.AutoMapperProcessor.process(Unknown Source) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:1023) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:939) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1267) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1382) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1234) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:916) at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104) at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152) at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100) at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94) at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:239) at org.jetbrains.jps.incremental.java.JavaBuilder.lambda$compileJava$2(JavaBuilder.java:519) at org.jetbrains.jps.incremental.java.JavaBuilder.invokeJavac(JavaBuilder.java:582) at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.jav

linpeilie commented 11 months ago

暂时不支持内部类

linpeilie commented 11 months ago

刚刚更新了 1.3.6-SNAPSHOT 版本,兼容了下内部类,可以试下有没有问题,在pom文件中指定 SNAPSHOT 仓库即可:

<repositories>
    <repository>
        <id>apache.snapshots</id>
        <name>Apache Development Snapshot Repository</name>
        <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
richwxd commented 11 months ago

不好用,莫名其妙的就出空指针错误了。maven-compiler-plugin->3.11.0; target->11; jdk->openjdk17; mapstruct-plus->1.3.5; spring-boot->2.7.17 报错. 而换成 maven-compiler-plugin->3.11.0; target->11; jdk->openjdk17; mapstruct-plus->1.3.1; spring-boot->2.7.17 可以编译

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <annotationProcessorPaths>
            <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${lombok.version}</version>
            </path>
            <path>
                <groupId>io.github.linpeilie</groupId>
                <artifactId>mapstruct-plus-processor</artifactId>
                <version>${mapstruct-plus.version}</version>
            </path>
            <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok-mapstruct-binding</artifactId>
                <version>0.2.0</version>
            </path>
            <path>
                <groupId>net.dreamlu</groupId>
                <artifactId>mica-auto</artifactId>
                <version>${mica-auto.version}</version>
            </path>
        </annotationProcessorPaths>
    </configuration>
</plugin>
linpeilie commented 11 months ago

不好用,莫名其妙的就出空指针错误了。maven-compiler-plugin->3.11.0; target->11; jdk->openjdk17; mapstruct-plus->1.3.5; spring-boot->2.7.17 报错. 而换成 maven-compiler-plugin->3.11.0; target->11; jdk->openjdk17; mapstruct-plus->1.3.1; spring-boot->2.7.17 可以编译

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <annotationProcessorPaths>
            <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${lombok.version}</version>
            </path>
            <path>
                <groupId>io.github.linpeilie</groupId>
                <artifactId>mapstruct-plus-processor</artifactId>
                <version>${mapstruct-plus.version}</version>
            </path>
            <path>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok-mapstruct-binding</artifactId>
                <version>0.2.0</version>
            </path>
            <path>
                <groupId>net.dreamlu</groupId>
                <artifactId>mica-auto</artifactId>
                <version>${mica-auto.version}</version>
            </path>
        </annotationProcessorPaths>
    </configuration>
</plugin>

看下我的回复,试下最新的snapshot版本

richwxd commented 11 months ago

试了snapshot,报错信息不一样,又一路退回1.3.1才编译过去的

linpeilie commented 11 months ago

试了snapshot,报错信息不一样,又一路退回1.3.1才编译过去的

报错信息是什么,贴下看呢

richwxd commented 11 months ago

报错信息是把很多行,变成一行了,有空我贴一下