ssh注入dao报错,求解?急~~~~

Artemis丶月 2013-04-24 11:56:56
求大神搭救~,莫名问题

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AdminAction': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.zwd.service.UserService com.zwd.action.AdminAction.userService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.zwd.dao.BaseDao com.zwd.service.impl.BaseServiceImpl.baseDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.zwd.dao.BaseDao] is defined: expected single matching bean but found 2: [moneyDao, userDao]


两个dao都是继承baseDao的,我估计是这里原因出错

@Component("moneyDao")
public class MoneyDaoImpl extends BaseDaoImpl<Money> implements MoneyDao {

}



@Component("userDao")
public class UserDaoImpl extends BaseDaoImpl<User> implements UserDao {

}


我在applicationContext.xml配置理由家这么一项
default-autowire="byName"

但是还是报错,求大神搭救~
比较急~~~~~
...全文
129 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Artemis丶月 2013-04-29
  • 打赏
  • 举报
回复
问题解决了,虽然和你们说的没什么关系
cscxxx 2013-04-25
  • 打赏
  • 举报
回复
No unique bean of type [com.zwd.dao.BaseDao] is defined: expected single matching bean but found 2: [moneyDao, userDao] 同类型class有多个实例的解决方案的一种方案是继续延用autowired,不过通过@Qualifier指明是哪个名字的bean 另外一种方案是使用@Resource这个注解,其功能与@autowired差不多,但是可以通过指定bean name或bean type注入相关bean,默认是按name注入,比autowired灵活很多 网上很多说明
lc328 2013-04-25
  • 打赏
  • 举报
回复
No unique bean of type

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧