SSHの3大フレームワークを統合する注釈時報An AnnotationConfiguration instance is required to use

3425 ワード

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: An AnnotationConfiguration instance is required to use     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)     at java.security.AccessController.doPrivileged(Native Method)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)     ... 46 more Caused by: org.hibernate.MappingException: An AnnotationConfiguration instance is required to use     at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1619)     at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1574)     at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1553)     at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1527)     at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)     at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:601)     at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
    ... 56 more
ソリューション:
springのプロファイルをsessionFactoryの場所のclassにアセンブリする
org.springframework.orm.hibernate3.LocalSessionFactoryBean
に改心
org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
Springのセッションファクトリにhibernateファイルが導入されているかどうかを確認します
	<bean id="sessionFactory"

		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

		<property name="configLocation" value="classpath:hibernate.cfg.xml">

		</property>

	</bean>