执行maven install的时候出现下面的错误:

找不到com.sun.beans.introspect.PropertyInfo的类文件_反射

 找到代码中报错的地方:

PropertyDescriptor pd = null;
try {
pd = new PropertyDescriptor(fields[j].getName(),entity.getClass());
}catch (IntrospectionException e1) {
e1.printStackTrace();
}
Method getMethod = pd.getReadMethod();

原来是我们在创建PropertyDescriptor  的时候出现的错误,这个地方是为了获取实体类的get方法,来读取对象中的值,我们找到这个类的构造方法

找不到com.sun.beans.introspect.PropertyInfo的类文件_无法加载_02

之前也遇到过 com.sun 这一类的jar无法加载,比如之前的Base64 也是在com.sun 下面,每次从启动的时候也是无法加载

如何解决:引入该类:

import org.springframework.beans.BeanUtils;

  PropertyDescriptor pd = null;
/*
* try {
* pd = new PropertyDescriptor(fields[j].getName(),entity.getClass());
* }catch (IntrospectionException e1) {
* e1.printStackTrace();
* }
*/

pd=BeanUtils.getPropertyDescriptor(entity.getClass(),fields[j].getName());
Method getMethod = pd.getReadMethod();

希望对你有所帮助