图片无法上传,报错信息如下:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.hibernate.cfg.Configuration]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: net/sf/cglib/transform/ClassFilter
==========================================================================================================
我的application.xml配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans" default-autowire="byName">
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:StudentManageSystem/src/hibernate.cfg.xml"></property>
</bean>
<bean id="userDao" class="cn.jbit.accp.dao.impl.UserDaoImpl">
</bean>
<bean id="userService" class="cn.jbit.accp.service.impl.UserServiceImpl">
</bean>
<bean id="userAction" class="cn.jbit.accp.action.UserAction" scope="prototype">
</bean>
</beans>
==========================================================================================================
UserDao如下:
package cn.jbit.accp.dao;import java.util.List;import cn.jbit.accp.entity.UsersTable;
/**
* 数据库操作接口
* @author PANJIE
*
*/
public interface UserDao {
public List<UsersTable> findUser(UsersTable user);
}
==========================================================================================================
UserDao的实现类如下:
package cn.jbit.accp.dao.impl;import java.util.List;import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;import cn.jbit.accp.dao.UserDao;
import cn.jbit.accp.entity.UsersTable;public class UserDaoImpl extends HibernateDaoSupport implements UserDao { private SessionFactory sessionFactory;
@Override
public List<UsersTable> findUser(UsersTable user) {
// TODO Auto-generated method stub
return this.getHibernateTemplate().find("from UsersTable u where u.userName=? and u.userPwd=?",new Object[]{user.getUserName(),user.getUserPwd()});
}
}
怎么解决啊,网上搜索总是出差错
==========================================================================================================
我的application.xml配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans" default-autowire="byName">
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:StudentManageSystem/src/hibernate.cfg.xml"></property>
</bean>
<bean id="userDao" class="cn.jbit.accp.dao.impl.UserDaoImpl">
</bean>
<bean id="userService" class="cn.jbit.accp.service.impl.UserServiceImpl">
</bean>
<bean id="userAction" class="cn.jbit.accp.action.UserAction" scope="prototype">
</bean>
</beans>
==========================================================================================================
UserDao如下:
package cn.jbit.accp.dao;import java.util.List;import cn.jbit.accp.entity.UsersTable;
/**
* 数据库操作接口
* @author PANJIE
*
*/
public interface UserDao {
public List<UsersTable> findUser(UsersTable user);
}
==========================================================================================================
UserDao的实现类如下:
package cn.jbit.accp.dao.impl;import java.util.List;import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;import cn.jbit.accp.dao.UserDao;
import cn.jbit.accp.entity.UsersTable;public class UserDaoImpl extends HibernateDaoSupport implements UserDao { private SessionFactory sessionFactory;
@Override
public List<UsersTable> findUser(UsersTable user) {
// TODO Auto-generated method stub
return this.getHibernateTemplate().find("from UsersTable u where u.userName=? and u.userPwd=?",new Object[]{user.getUserName(),user.getUserPwd()});
}
}
怎么解决啊,网上搜索总是出差错
说是找不到这个类的定义,看看是不是缺少jar包
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:orcl" />
<property name="user" value="scott" />
<property name="password" value="tiger" />
<property name="initialPoolSize" value="2" />
<property name="maxPoolSize" value="200" />
<property name="minPoolSize" value="1" />
<property name="maxIdleTime" value="120" />
<property name="acquireIncrement" value="5" />
<property name="idleConnectionTestPeriod" value="60" />
</bean>再配置sessionFactory试试吧<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>cn/bean/User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.hbm2ddl.auto = update
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
hibernate.show_sql=ture
hibernate.format_sql=true
</value>
</property>
</bean>