被夹毛局的程序员 2017-10-11 08:03 采纳率: 0%
浏览 1851

关于tomcat启动spring注入的时候报找到2个bean

我确定在自己的类中Service只有一个实现..但是bean不唯一的错..我现在也很迷茫..用的开发工具是IDEA
求教各位大神
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'baseInfoController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.ljljob.p2p.core.base.service.ISystemDictionaryItemService com.ljljob.p2p.website.controller.BaseInfoController.systemDictionaryItemService; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.ljljob.p2p.core.base.service.ISystemDictionaryItemService] is defined: expected single matching bean but found 2: systemDictionaryItemServiceImpl,ISystemDictionaryItemService

spring配置如下
<!--1:配置注解解析-->
context:annotation-config/

<!--2:加载外部资源-->
<context:property-placeholder location="classpath:db.properties,classpath:sms.properties,classpath:email.properties"/>

<!--3:配置dataSource-->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
    <property name="driverClassName" value="${jdbc.driverClassName}"/>
    <property name="url" value="${jdbc.url}"/>
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>
</bean>
<!--4:配置sesssionFactory-->
<bean id="sqlsessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="configLocation" value="classpath:mybatis.cfg.xml"/>
    <property name="mapperLocations" value="classpath:com/ljljob/p2p/*/*/mapper/*Mapper.xml"/>
    <property name="typeAliasesPackage" value="com.ljljob.p2p"/>
</bean>
<!--5:配置事务管理器-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"/>
</bean>
<!--6:配置事务处理-->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="query*" read-only="true" propagation="SUPPORTS"/>
        <tx:method name="select*" read-only="true" propagation="SUPPORTS"/>
        <tx:method name="get*" read-only="true" propagation="SUPPORTS"/>
        <tx:method name="list*" read-only="true" propagation="SUPPORTS"/>
        <tx:method name="*" propagation="REQUIRED"/>
    </tx:attributes>
</tx:advice>

<!--7:配置AOP-->
<aop:config>
    <aop:pointcut id="txPointCut" expression="execution(* com.ljljob.p2p..service.*.*(..))"/>
    <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointCut"/>
</aop:config>

<!--配置mapper扫描器-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.ljljob.p2p.core"/>
</bean>

  • 写回答

4条回答 默认 最新

  • 被夹毛局的程序员 2017-10-11 08:10
    关注

    问题补充:上午调试都是好的..突然一下就报这个错了..不知道是不是我把配置文件搞坏了?所有的service都报bean不唯一的异常

    评论

报告相同问题?

悬赏问题

  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器