各种异常解决

1: ids for this class must be manually assigned befor数据表里面设置了主键,而Hibernate的.hbm里主键生成方式设置为assigned的时候,
<generator class="assigned"/>

出现了 ids for this class must be manually assigned before calling save()异常,在网上找了一下,才发现,hibernate出现这个错误的原因有可能因为,你的表中有个主键。 但是在执行save()的时候却没有给Id设置值,如调用xxx.setId(..)等方法,才会出现。


2: Caused by: java.lang.NoClassDefFoundError:org/apache/commons/pool/impl/GenericObjectPool
//异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/base.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool

Caused by: java.lang.NoClassDefFoundError: org/apache/commons/pool/impl/GenericObjectPool 
//缺少Apache的commons-pool-1.x.jar,可以在
//http://commons.apache.org/downloads/download_pool.cgi 或
//www.findjar.com上下载对应的jar包


3:
Caused by: java.lang.NoSuchMethodError: org.apache.commons.pool.impl.GenericObjectPool: method <init>()V not found

看见org.apache.commons.pool.impl.GenericObjectPool,一开始以为少了commons-pool这个jar.但后来发现lib里有commons-pool-1.0.1.jar这个jar啊,于是再google一躺,发现是版本问题,换了个commons-pool-1.4.jar就没问题了.

4:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

缺少jakarta-commons的commons-logging.jar

你可能感兴趣的:(java,apache,Hibernate,bean,Google)