错误描述:
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.commons.beanutils.ConvertUtilsBean.<init>(ConvertUtilsBean.java:157)
at org.apache.commons.beanutils.BeanUtilsBean.<init>(BeanUtilsBean.java:117)
at org.apache.commons.beanutils.BeanUtilsBean$1.initialValue(BeanUtilsBean.java:68)
at org.apache.commons.beanutils.ContextClassLoaderLocal.get(ContextClassLoaderLocal.java:153)
at org.apache.commons.beanutils.BeanUtilsBean.getInstance(BeanUtilsBean.java:80)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:456)
原因:使用beanutils需要的jar包:
- commons-beanutils.jar;
- commons-logging.jar;
而我只导入了commons-beanutils.jar,没有导入另外一个包
解决方法:导入commons-logging.jar包
错误描述:
com.sun.org.apache.commons.logging.LogConfigurationException: com.sun.org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by com.sun.org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
原因:导错包了
原本我应该导入org.apache.commons.beanutils.BeanUtils
而此时却导入了com.sun.org.apache.commons.beanutils.BeanUtils
解决方法:导入org.apache.commons.beanutils.BeanUtils包,删去com.sun.org.apache.commons.beanutils.BeanUtils。