<dependency> <groupId>org.alchemy-annotations</groupId> <artifactId>alchemy-annotations</artifactId> <version>1.0.0</version> </dependency> groovy compile group: 'org.alchemy-annotations', name: 'alchemy-annotations', version: '1.0.0' import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @Documented public @interface CustomAnnotation { } public class MyClass { public void myMethod() { } } import org.alchimy.annotations.*; public class CustomAnnotationProcessor implements AnnotationProcessor { @Override public void process(Object o, Annotation annotation) { if (annotation instanceof CustomAnnotation) { CustomAnnotation customAnnotation = (CustomAnnotation) annotation; System.out.println(value); } } } public class MyApp { public static void main(String[] args) { Alchimy.registerProcessor(CustomAnnotation.class, new CustomAnnotationProcessor()); MyClass myObject = new MyClass(); } }


上一篇:
下一篇:
切换中文