前几天用AnnotationSessionFactoryBean 注解方式代替*.hbm.xml时扫描映射实休文件后报错

吐操一下.Hibernate真心配置麻烦.不是VO. 是sessionFactory

Hibernate版本 支持 hibernate-jpa-2.0-api-1.0.0.Final.jar

hibernate3.5以前的版本使用注解使用hibernate-annotations.jar以及ejb-persistence.jar。其实这里的ejb-persistence.jar和前面提到的hibernate-jpa-2.0-api-1.0.0.Final.jar功能一样,实现持久化功能。但hibernate-jpa-2.0-api-1.0.0.Final.jar在ejb-persistence.jar基础上新添了一些类,估计是hibernate官方对jpa的扩展

前几天用注解方式代替*.hbm.xml时扫描映射文件的方法


报错如下:       org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginAction': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibLoginDAOImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/annotations/Entity


ejb3-persistence.jar hibernate-jpa-2.0-api-1.0.1.Final.jarp 这两个是有冲突的.


给出两方配置方式:


    	
		
			
		
		
			
				
					org.hibernate.dialect.MySQLDialect
				
				true
				true
				update
			
		
		
			
				com.danlan.vo.Knowledge
				com.danlan.vo.MjhUserinfo
			
		
	
	

当然.这里也可以改为目录扫描




com.danlan.vo.Knowledge
com.danlan.vo.MjhUserinfo


二:

	
	
		
			
		
		
			
				
					org.hibernate.dialect.MySQLDialect
				
				true
				true
				update
			
		
		
		 	classpath:/com/danlan/vo/*.hbm.xml   
		


你可能感兴趣的:(前几天用AnnotationSessionFactoryBean 注解方式代替*.hbm.xml时扫描映射实休文件后报错)