小编mis*_*ous的帖子

错误的服务配置文件,或构造Processor对象时抛出的异常

我在Java中编写一个简单的自定义注释并遇到问题.这是我的代码的主要部分.

LogMeCustomAnnotation.java

package fun.n.learn.annotation;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

// We need this annotation only till before compilation.
@Retention(RetentionPolicy.SOURCE)
// This is a simple custom annotation.
public @interface LogMeCustomAnnotation {

}
Run Code Online (Sandbox Code Playgroud)

LogMeCustomAnnotationProcessor.java

package fun.n.learn.annotation;

import java.util.Set;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Messager;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;

// List the custom annotations that are supported.
@SupportedAnnotationTypes({ "fun.n.learn.annotation.LogMeCustomAnnotation" })
// Extend AbstractProcessor. This will let you process.
public class LogMeCustomAnnotationProcessor extends AbstractProcessor {

    @Override
    public boolean process(Set<? extends TypeElement> annotations,
            RoundEnvironment …
Run Code Online (Sandbox Code Playgroud)

java annotations maven

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

annotations ×1

java ×1

maven ×1