kotlin - 如何从 Kotlin AllOpen 插件中排除注释?
问题描述
我正在使用 Axon Framework,我可以在其中注释我的域类@Aggregate
(使用 Spring 的 @Component 进行元注释)。然后我必须通过final
明确标记它们来为我拥有的每个私有方法/字段道歉。
我认为在我的情况下,我很擅长将课程标记为打开,所以我想在@Aggregate
从spring
插件中排除的同时手动完成,但我找不到这样做的方法。
解决方案
workaround
According to the documentation, the spring
plugin uses all-open
under the hood by just listing Spring annotations, while supporting the meta-annotating. So, we do exactly that, but we don't specify list @Component
, so in our code, we must use the stereotypes (repository, service, etc.). This way it doesn't pick up the @Aggregate
:
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<configuration>
<compilerPlugins>
<!-- instead of 'spring' -->
<plugin>all-open</plugin>
</compilerPlugins>
<pluginOptions>
<!-- todo check up on https://stackoverflow.com/questions/56537496 -->
<!-- listing all spring annotations except @Component -->
<option>all-open:annotation=org.springframework.stereotype.Service</option>
<option>all-open:annotation=org.springframework.stereotype.Controller</option>
<option>all-open:annotation=org.springframework.data.repository.Repository</option>
<option>all-open:annotation=org.springframework.context.annotation.Configuration</option>
<option>all-open:annotation=org.springframework.boot.test.context.SpringBootTest</option>
<option>all-open:annotation=org.springframework.cache.annotation.Cacheable</option>
<option>all-open:annotation=org.springframework.transaction.annotation.Transactional</option>
<option>all-open:annotation=org.springframework.scheduling.annotation.Async</option>
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
推荐阅读
- unit-testing - 如何找出函数在 Jest 中通过测试的原因?
- python - 给定一个字符串列表,如果任何值等于列表中的值,我想将字典的值添加到新字典中
- google-cloud-platform - 在 BigQuery 中导出表格时,我可以控制共享文件的大小和/或数量吗?
- javascript - 如果单击取消按钮,如何使 Javascript“确认()”取消对新页面的请求?
- java - 如何在 json-binding (java ee 8) 中编写将空值转换为“”的反序列化器?
- node.js - 在 Heroku 上部署应用程序时如何修复 H20 错误?
- asp.net - 如何使用 devexpress 在弹出窗口中获取清单的选定值
- apache-kafka - Kafka 服务器 - 在 JAAS 中找不到“KafkaServer”
- javascript - 在添加到 javascript 数组之前检查重复项
- excel - SSIS:以编程方式根据 Web 查询结果创建新的 Excel 文件 - 如何保存 Web 查询表名称?