<span style="font-family: 'Microsoft YaHei'; background-color: rgb(255, 255, 255);">1.</span><span style="font-family: 'Microsoft YaHei'; color: rgb(255, 0, 0); background-color: rgb(255, 255, 255);"><strong>Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/LibBorrowManage-servlet.xml]; </strong></span>
配置dataSource的时候:<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> 这是原来的旧的,改为<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource">
2 java.lang.NoClassDefFoundError: org/hibernate/service/jta/platform/spi/JtaPl
产生原因是:
Hibernate4.3.X中,org.hibernate.service.jta.platform.spi.JtaPlatform类换成了:
org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
Hibernate用4.2.X及以下版本 或 Spring用4.0及以上版本
3 nested exception is java.lang.NoClassDefFoundError: Lorg/hibernate/cache/CacheProvider。
Hibernate3的时候, Hibernate的sessionfactory配置是: <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
Hibernate4已经把CacheProvider相关的接口和类移除,用org.springframework.orm.hibernate4.LocalSessionFactoryBean即可
替换org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean。
4.配置实体多对一 、一对多关系的时候出错:rg.hibernate.AnnotationException: mappedBy reference anunknown target entity property:
这里出错是因为@OneToMany(mappedBy=" ")这里的mappedBy写错,应该写在‘多方’那里ManyToOne下面的属性名。如Reader 和借阅表BorrowInfo是一对多的关系。则
多方:
@ManyToOne
@JoinColumn(name="ReaderId")
private Reader Reader;
一方(这里的ReaderId是对应多方Reader属性名Reader)
@OneToMany(mappedBy="Reader") private Set<BorrowInfo> BorrowInfoes;