我想在生成的(由mapstruct)类中禁用@Generate注释。
I try args-Amapstruct.suppressGeneratorTimestamp=true
和-Amapstruct.suppressGeneratorVersionInfoComment=true
,但仍然没有关闭注释
在mapstruct的源代码中,我发现类GeneratedType
,它在构造函数中声明了一个字段generatedTypeAvailable
,这影响了模板GeneratedType.ftl
:
<#if !generatedTypeAvailable>/*</#if>
@Generated(
value = "org.mapstruct.ap.MappingProcessor"<#if suppressGeneratorTimestamp == false>,
date = "${.now?string("yyyy-MM-dd'T'HH:mm:ssZ")}"</#if><#if suppressGeneratorVersionComment == false>,
comments = "version: ${versionInformation.mapStructVersion}, compiler: ${versionInformation.compiler}, environment: Java ${versionInformation.runtimeVersion} (${versionInformation.runtimeVendor})"</#if>
)<#if !generatedTypeAvailable>
*/</#if>
那么,如何设置字段值generatedTypeAvailable
为false
呢?
目前无法禁用@Generated
注释的创建。你为什么要这么做?
你能做的是:
- 使用
-Amapstruct.suppressGeneratorTimerstamp=true
抑制时间戳值 - 使用
-Amapstruct.suppressGeneratorVersionInfoComment
禁用版本