先建两个注解 分别为 Table 和 Column
package com.hk.test; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface Table { String value(); }
package com.hk.test; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface Column { String value(); }
然后新建一个 bean 类 Filter.java (本类可根据自己需求更改,只要样式不变就好)
package com.hk.test; @Table("user") public class Filter { @Column("id") private int id; @Column("user_name") private String userName; @Column("age") private int age; @Column("email") private String email;