isAnnotationPresent(注解类名)方法可以判断有没有使用某个注解;
本案例说明:注解信息可以被反射机制解析到;前提是该注解定义了 @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)//只用于方法上面
@Inherited//支持继承
@Documented//支持文档化
@Retention(RetentionPolicy.RUNTIME)//保存到class字节码文件中,并且可以被反射机制读取
public @interface ReflectAnnotationTest_DataBase {
String driver();
String url();
String user();
String password();
}