利用反射机制读取注解(初步)
初步实现注解的读取 读取注解=注解的建立+读取注解的实现 此处实现的是学生的相关注解的实现: 1.建立SxtStudent类,包含基本信息,并get,set; 2.建立SxtTable注解,包含一个值,记录表格的名字; 3.建立SxtField注解,包含SxtStudent类的基本属性的属性,记录表格基本信息的类型; 4.建立Demo类,进行测试,输出SxtStudent类的全部注解,输出SxtStudent的指定注解,输出SxtStudent类的所有属性和指定属性的注解 以下是代码: 1.SxtStudent package com . sxt . reflectingtest ; @SxtTable ( "tb_student" ) public class SxtStudent { @SxtField ( columnName = "id" , type = "int" , length = 10 ) private int id ; @SxtField ( columnName = "age" , type = "int" , length = 3 ) private int age ; @SxtField ( columnName = "sname" , type = "varchar" , length = 10 ) private String studentName