Closed qinkangdeid closed 8 months ago
我的kotlin版本是1.9.22 按照jimmer文档配置的话 complie的时候报错:kotlin.enums.EnumEntriesKt
我尝试把kotlin-maven-symbol-processing插件升级版本到 1.6 是可以编译成功的 但不会有mapstruct的生成代码 只有ksp的生成代码
这个结果是把 maven-complie插件注释 把在kotlin-maven-complie插件里的 kapt注释掉的结果:
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
<!-- kotlin插件 顺序不能乱 顺序不能乱 java编译插件(maven-compiler)要在下面 -->
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
<!-- <execution>-->
<!-- <id>kapt</id>-->
<!-- <goals>-->
<!-- <goal>kapt</goal> <!– You can skip the <goals> element if you enable extensions for the plugin –>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <sourceDirs>-->
<!-- <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>-->
<!-- <sourceDir>${project.basedir}/src/main/java</sourceDir>-->
<!-- </sourceDirs>-->
<!-- <!– kapt是maps官方示例添加的 还要配合maven-compiler才能生成实现类 https://github.com/mapstruct/mapstruct-examples/blob/main/mapstruct-kotlin/pom.xml –>-->
<!-- <annotationProcessorPaths>-->
<!-- <annotationProcessorPath>-->
<!-- <groupId>org.mapstruct</groupId>-->
<!-- <artifactId>mapstruct-processor</artifactId>-->
<!-- <version>${mapstruct.version}</version>-->
<!-- </annotationProcessorPath>-->
<!--<!– 这里jimmer文档没说要放 但是放不放效果都一样 –>-->
<!-- <annotationProcessorPath>-->
<!-- <groupId>org.babyfish.jimmer</groupId>-->
<!-- <artifactId>jimmer-mapstruct-apt</artifactId>-->
<!-- <version>${jimmer.version}</version>-->
<!-- </annotationProcessorPath>-->
<!-- <!– meta-json需要 –>-->
<!-- <annotationProcessorPath>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-configuration-processor</artifactId>-->
<!-- <version>${spring-boot.version}</version>-->
<!-- </annotationProcessorPath>-->
<!-- </annotationProcessorPaths>-->
<!-- </configuration>-->
<!-- </execution>-->
</executions>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
<plugin>no-arg</plugin>
<compilerPlugin>ksp</compilerPlugin>
</compilerPlugins>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</annotationProcessorPath>
<annotationProcessorPath>
<groupId>org.babyfish.jimmer</groupId>
<artifactId>jimmer-mapstruct-apt</artifactId>
<version>${jimmer.version}</version>
</annotationProcessorPath>
</annotationProcessorPaths>
<pluginOptions>
<!-- Call instance initializers in the synthetic constructor -->
<!-- <option>no-arg:invokeInitializers=true</option> -->
</pluginOptions>
<jvmTarget>${java.version}</jvmTarget>
</configuration>
<!-- 将spring jpa需要的配置类 无参构造自动开放 -->
<dependencies>
<dependency>
<groupId>com.dyescape</groupId>
<!-- 依赖KSP的Maven插件 -->
<artifactId>kotlin-maven-symbol-processing</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.babyfish.jimmer</groupId>
<!-- 应用Jimmer的KSP代码生成器 -->
<artifactId>jimmer-ksp</artifactId>
<version>${jimmer.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-noarg</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- maps官方示例还是要添加这个maven-compiler =========== -->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <version>3.8.1</version>-->
<!-- <configuration>-->
<!-- <proc>none</proc>-->
<!-- <source>${kotlin.compiler.jvmTarget}</source>-->
<!-- <target>${kotlin.compiler.jvmTarget}</target>-->
<!-- <compilerArgs>-->
<!-- <arg>-Amapstruct.verbose=true</arg>-->
<!-- </compilerArgs>-->
<!-- </configuration>-->
<!-- <executions>-->
<!-- <!– Replacing default-compile as it is treated specially by maven –>-->
<!-- <execution>-->
<!-- <id>default-compile</id>-->
<!-- <phase>none</phase>-->
<!-- </execution>-->
<!-- <!– Replacing default-testCompile as it is treated specially by maven –>-->
<!-- <execution>-->
<!-- <id>default-testCompile</id>-->
<!-- <phase>none</phase>-->
<!-- </execution>-->
<!-- <execution>-->
<!-- <id>java-compile</id>-->
<!-- <phase>compile</phase>-->
<!-- <goals>-->
<!-- <goal>compile</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- <execution>-->
<!-- <id>java-test-compile</id>-->
<!-- <phase>test-compile</phase>-->
<!-- <goals>-->
<!-- <goal>testCompile</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
</plugins>
</build>
gradle的配置是完全没问题的
Mapstruct基于Annotation processor,Kotlin生态下Kapt已经停止维护,随着kotlin版本的不管升级,问题越来越多,从未间断。已经不堪重负。
进过考虑,Jimmer放弃支持kotlin下的map-struct。后期会在文档中说明此事。
鉴于issue-399的问题,转而想使用mapstruct生成一个POJO的参数类,想要让其能够转换为jimmer的entity 这样可以转而使用example查询
但是配置完编译无法通过
根据mapstruct文档配置: https://github.com/mapstruct/mapstruct-examples/blob/main/mapstruct-kotlin/pom.xml 在没有jimmer依赖的时候可以正常生成Converter的实现类
加上jimmer依赖后编译生成报错:
是不是我的什么配置影响了
jimmer-mapstruct-apt
的运行???把jimmer文档中 https://babyfish-ct.gitee.io/jimmer-doc/docs/object/view/mapstruct的配置后 只要不是jimmer的动态对象都没问题 换成转换jimmer动态实体的时候就报错
大佬 劳烦有空帮忙看看这个配置有什么问题
示例demo:springboot-jimmer-maven.zip
complie即报错 springboot-jimmer-maven.zip