关于spring mvc 3.0注解,注入失败的问题
使用注解注入失败:--dao层interfaceLoginUserDao(接口)publicclassLoginUserDaoImplimplementsLoginUse...
使用注解注入失败:
--dao层
interface LoginUserDao(接口)
public class LoginUserDaoImpl implements LoginUserDao(实现类)
--service层
interface LoginUserService(接口)
//使用注解注入dao层对象
@Service
public class LoginUserServiceImpl implements LoginUserService{
@Resource(type=LoginUserDao.class,name="loginUserDaoImpl")
private LoginUserDao loginUserDaoImpl;
//方法...
}
--controller
//使用注解注入service层对象
@Controller
@RequestMapping("/userlogin.do")
public class UserLoginController{
@Resource(type=LoginUserService.class,name="loginUserServiceImpl")
private LoginUserService loginUserServiceImpl;
//方法...
}
启动错误:
Error creating bean with name 'loginUserServiceImpl':Injection of resource dependencies failed;No bean named 'loginUserDaoImpl' is defined
No bean named 'loginUserDaoImpl' is defined;
Error creating bean with name 'loginUserServiceImpl': Injection of resource dependencies failed;
No bean named 'loginUserDaoImpl' is defined 展开
--dao层
interface LoginUserDao(接口)
public class LoginUserDaoImpl implements LoginUserDao(实现类)
--service层
interface LoginUserService(接口)
//使用注解注入dao层对象
@Service
public class LoginUserServiceImpl implements LoginUserService{
@Resource(type=LoginUserDao.class,name="loginUserDaoImpl")
private LoginUserDao loginUserDaoImpl;
//方法...
}
--controller
//使用注解注入service层对象
@Controller
@RequestMapping("/userlogin.do")
public class UserLoginController{
@Resource(type=LoginUserService.class,name="loginUserServiceImpl")
private LoginUserService loginUserServiceImpl;
//方法...
}
启动错误:
Error creating bean with name 'loginUserServiceImpl':Injection of resource dependencies failed;No bean named 'loginUserDaoImpl' is defined
No bean named 'loginUserDaoImpl' is defined;
Error creating bean with name 'loginUserServiceImpl': Injection of resource dependencies failed;
No bean named 'loginUserDaoImpl' is defined 展开
展开全部
import org.springframework.stereotype.Repository;
@Repository
public class LoginUserDaoImpl implements LoginUserDao(实现类)
加上@Repository注解给 LoginUserDaoImpl
@Repository
public class LoginUserDaoImpl implements LoginUserDao(实现类)
加上@Repository注解给 LoginUserDaoImpl
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询