如何在自定义注释处理器中包括依赖项

时间:2019-06-17 08:28:04

标签: gradle annotations

我使用javapoet编写了ProtoBufAnnotationProcessor

我已经在build.gradle

中添加了依赖项
implementation group: 'com.squareup', name: 'javapoet', version: '1.11.1'

当我在另一个包含依赖项的项目中测试此批注时

        <dependency>
            <groupId>pers.a9043</groupId>
            <artifactId>protobuf-annotation-processor</artifactId>
            <version>1.0.0</version>
            <optional>true</optional>
        </dependency>

我发现了错误

javax.annotation.processing.Processor: Provider pers.a9043.ProtoBufAnnotationProcessor could not be instantiated: java.lang.NoClassDefFoundError: com/squareup/javapoet/xxx

我必须同时包括处理器模块和Spring Boot模块的javapoet依赖项,才能解决此错误。

但是我不想在Spring Boot模块中包含此依赖项。看起来很奇怪。

0 个答案:

没有答案