在我的 spring mvc+hibernate+annotations 项目中,我有这三个类
UserServiceImpl.java
@Service("userService")
public class UserServiceImpl implements UserService {
@Autowired
private UserDAO userDAO;
//other codes
}
UserDAOImpl.java
@Repository("userDAO")
public class UserDAOImpl implements UserDAO {
@Autowired
private SessionFactory sessionFactory;
//other codes
}
注册控制器.java
@Controller
@RequestMapping("/registration.htm")
public class RegistrationController {
@Autowired
private UserService userService;
//other codes
}
在我的dispatcher-servlet.xml我添加了以下内容
<context:annotation-config />
<context:component-scan base-package="com.alw.controllers,com.alw.DAOs,com.alw.services" />
和
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
当我运行该项目时,出现以下异常:
Error creating bean with name 'registrationController':
Injection of autowired dependencies failed;
nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire field: private com.alw.services.UserService
com.alw.controllers.RegistrationController.userService;
和
Error creating bean with name 'sessionFactory' defined in ServletContext resource
[/WEB-INF/dispatcher-servlet.xml]:
Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError:
org/apache/commons/pool/impl/GenericObjectPool
有人能指出我在哪里失踪吗?
这已经占用了我今天的一整天。
编辑:
我添加了 commons.pool 但没有结果。
我有这些例外。
Error creating bean with name 'registrationController':
Error creating bean with name 'userService':
Error creating bean with name 'userDAO':
Error creating bean with name 'sessionFactory' defined in ServletContext
resource [/WEB-INF/dispatcher-servlet.xml]:
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError:
Could not initialize class org.hibernate.cfg.AnnotationConfiguration
谢谢....