spring - org.springframework.orm.hibernate4 not found -


i'm try sessionfactory bean in jtest it's throws exception:

org.springframework.beans.factory.cannotloadbeanclassexception: cannot find class [org.springframework.orm.hibernate4.localsessionfactorybean] bean name 'sessionfactory' defined in class path resource [spring.hibernate.xml]; nested exception java.lang.classnotfoundexception: org.springframework.orm.hibernate4.localsessionfactorybean 

my jtestcode:

@test public void test(){      applicationcontext ac=new classpathxmlapplicationcontext(new string[]{"classpath:spring.xml","classpath:spring.hibernate.xml"});      sessionfactory session=(sessionfactory) ac.getbean("sessionfactory");     if(session==null){         system.out.println("it's null");     }  } 

here spring.hibernate.xml:

<!-- jndi方式配置数据源 --> <!-- <bean id="datasource" class="org.springframework.jndi.jndiobjectfactorybean"> <property name="jndiname" value="${jndiname}"></property> </bean> -->  <!-- 配置数据源 --> <bean name="datasource" class="com.alibaba.druid.pool.druiddatasource" init-method="init" destroy-method="close">     <property name="url" value="${jdbc_url}" />     <property name="username" value="${jdbc_username}" />     <property name="password" value="${jdbc_password}" />      <!-- 初始化连接大小 -->     <property name="initialsize" value="0" />     <!-- 连接池最大使用连接数量 -->     <property name="maxactive" value="20" />     <!-- 连接池最大空闲 -->     <property name="maxidle" value="20" />     <!-- 连接池最小空闲 -->     <property name="minidle" value="0" />     <!-- 获取连接最大等待时间 -->     <property name="maxwait" value="60000" />      <!-- <property name="poolpreparedstatements" value="true" /> <property name="maxpoolpreparedstatementperconnectionsize" value="33" /> -->      <property name="validationquery" value="${validationquery}" />     <property name="testonborrow" value="false" />     <property name="testonreturn" value="false" />     <property name="testwhileidle" value="true" />      <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->     <property name="timebetweenevictionrunsmillis" value="60000" />     <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->     <property name="minevictableidletimemillis" value="25200000" />      <!-- 打开removeabandoned功能 -->     <property name="removeabandoned" value="true" />     <!-- 1800秒,也就是30分钟 -->     <property name="removeabandonedtimeout" value="1800" />     <!-- 关闭abanded连接时输出错误日志 -->     <property name="logabandoned" value="true" />      <!-- 监控数据库 -->     <!-- <property name="filters" value="stat" /> -->     <property name="filters" value="mergestat" /> </bean>  <!-- 配置hibernate session工厂 --> <bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean">     <property name="datasource" ref="datasource" />     <property name="hibernateproperties">         <props>             <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>             <prop key="hibernate.dialect">${hibernate.dialect}</prop>             <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>             <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>         </props>     </property> 

did forget add jar or jar include org.springframework.orm.hibernate4.localsessionfactorybean? .i need

do have org.springframework.orm-n.n.n.jar in classpath?

have @ error message, make sure there aren't other spring or external libraries pre-requisites -- cause indirect classnotfounderror.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -