public static void main(String[] args) {
try {
BeanInfo beanInfo = Introspector.getBeanInfo(MyBean.class, Object.class);
for (var b : beanInfo.getMethodDescriptors()) {
System.out.println(b);
}
for (var a : beanInfo.getPropertyDescriptors()) {
System.out.println("-----------");
System.out.println(a);
}
} catch (IntrospectionException e) {
e.printStackTrace();
}
}
class MyBean {
private String id = null;
private String userName = null;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}