@Plugin(name = "MyPlugin", version = "1.0") public class MyPlugin { } public class MyPlugin { @Parameter(name = "timeout", defaultValue = "5000") private int timeout; @Parameter(name = "maxRetries", defaultValue = "3") public void setMaxRetries(@Parameter(name = "maxRetries") int maxRetries) { this.maxRetries = maxRetries; } } @SupportedAnnotationTypes("com.example.annotations.Plugin") public class PluginProcessor extends AbstractProcessor { @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element element : roundEnv.getElementsAnnotatedWith(Plugin.class)) { } return true; } } <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <annotationProcessorPaths> <path> <groupId>org.n52.faroe</groupId> <artifactId>faroe-annotations</artifactId> <version>1.0.0</version> </path> </annotationProcessorPaths> </configuration> </plugin> </plugins> </build>


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