Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframe.orm.hibernate3.HibernateTemplate] for bean with name 'hibernateTemplate' defined in class path resource [beans.xml]; nested exception is java.lang.ClassNotFoundException: org.springframe.orm.hibernate3.HibernateTemplate
Caused by: java.lang.ClassNotFoundException: org.springframe.orm.hibernate3.HibernateTemplate
我已经把需要的包都导入进去了
BEANS.XML
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <!-- 配置数据源 -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/test"/>
<property name="username" value="root"/>
<property name="password" value=""/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>com/sise/spring/po/Student.hbm.xml</value>
</list>
</property>
<!-- 配置Hibernate的SessionFactory的属性 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
</bean>
<!-- 配置HibernateTemplate -->
<bean id="hibernateTemplate" class="org.springframe.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- 配置Student持久化类的DAO Bean -->
<bean id="studentDao" class="com.sise.spring.dao.impl.StudentDaoImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"/>
</bean>
<!-- 配置业务实现类 -->
<bean id="studentService" class="com.sise.spring.service.impl.StudentServiceImpl">
<property name="studentDao" ref="studentDao"></property>
</bean>
</beans>
Caused by: java.lang.ClassNotFoundException: org.springframe.orm.hibernate3.HibernateTemplate
我已经把需要的包都导入进去了
BEANS.XML
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <!-- 配置数据源 -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/test"/>
<property name="username" value="root"/>
<property name="password" value=""/>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>com/sise/spring/po/Student.hbm.xml</value>
</list>
</property>
<!-- 配置Hibernate的SessionFactory的属性 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
</bean>
<!-- 配置HibernateTemplate -->
<bean id="hibernateTemplate" class="org.springframe.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- 配置Student持久化类的DAO Bean -->
<bean id="studentDao" class="com.sise.spring.dao.impl.StudentDaoImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"/>
</bean>
<!-- 配置业务实现类 -->
<bean id="studentService" class="com.sise.spring.service.impl.StudentServiceImpl">
<property name="studentDao" ref="studentDao"></property>
</bean>
</beans>
解决方案 »
- 很简单的SSH问题 java.lang.NullPointerException 在线等!!!
- ckfinder怎么用时间来作为上传文件的路径呢 java
- 叫法 求救 !!!新手
- struts的session问题
- java 修改 properties文件
- 发布WebService不能发布接口类返回值的问题
- Java连接数据库Sql语句报错问题,其实是正确……坐等答案……
- 为什么我生成的schema不起作用?
- 使用spirng aop ,配置transactioninterceptor事务不能回滚,什么原因?谢谢
- spring集成struts,运用aop
- java 时间和毫秒,相互转换的问题谢谢指教
- 谁会ssl呀 和ssh结合使用
这个是什么东西?
springframework好不?配置自己再改改吧。。
这个类在org.springframe.orm-x.x.jar这个包,你加了没在说你在类里输入org.springframe.orm.hibernate3.HibernateTemplate
,按住ctrl,用鼠标一点能进去的话,就说明加到项目里了,