Java 未调用自定义批注处理器.process()
我正在尝试创建一个自定义注释处理器,但它没有被调用。虽然它是being.init,但它似乎从未调用.process。任何帮助都将不胜感激 版本:Java 未调用自定义批注处理器.process(),java,maven,kotlin,annotations,annotation-processor,Java,Maven,Kotlin,Annotations,Annotation Processor,我正在尝试创建一个自定义注释处理器,但它没有被调用。虽然它是being.init,但它似乎从未调用.process。任何帮助都将不胜感激 版本: 科特林(1.3.72) JRE(11.0.7) 马文(3.8.0) 这是我从控制台的输出: [INFO] --- maven-compiler-plugin:3.8.0:compile (java-compile) @ mesh --- [INFO] Changes detected - recompiling the module! Proces
- 科特林(1.3.72)
- JRE(11.0.7)
- 马文(3.8.0)
[INFO] --- maven-compiler-plugin:3.8.0:compile (java-compile) @ mesh ---
[INFO] Changes detected - recompiling the module!
Processor is being init!!
Processor is done init!!
注释:
package my.path.annotations
@Target(AnnotationTarget.CLASS)
annotation class MyAnnotation()
注释处理器:
package my.path.annotations
import <...>
@SupportedAnnotationTypes("my.path.annotations.MyAnnotation")
class MyAnnotationProcessor : AbstractProcessor() {
private var elementUtils: Elements? = null
private var messager: Messager? = null
@Synchronized
override fun init(env: ProcessingEnvironment?) {
println("Processor is being init!!")
super.init(env);
elementUtils = env!!.elementUtils;
messager = env.messager;
println("Processor is done init!!")
}
override fun process(annotations: MutableSet<out TypeElement>?, roundEnv: RoundEnvironment): Boolean {
println("Processor is being run!!!")
return true
}
override fun getSupportedSourceVersion(): SourceVersion? = SourceVersion.latestSupported()
}
在类上使用:
@MyAnnotation
class SomeClass @Inject constructor(private val objectMapper: ObjectMapper) {
my.path.annotations.MyAnnotationProcessor
@MyAnnotation
class SomeClass @Inject constructor(private val objectMapper: ObjectMapper) {