2

我正在使用 Axon Framework,我可以在其中注释我的@Aggregate(使用 Spring 的 @Component 进行元注释)。然后我必须通过final明确标记它们来为我拥有的每个私有方法/字段道歉。

我认为在我的情况下,我很擅长将课程标记为打开,所以我想在@Aggregatespring插件中排除的同时手动完成,但我找不到这样做的方法。

4

1 回答 1

1

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>
于 2019-06-11T06:56:16.877 回答