在开发中我再applicationContext-dao.xml中加入了mapper扫描器

[html] view plain copy
  1. <!--mapper扫描器-->  
  2. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  
  3.     <!--扫描包路径,如果需要扫描多个包,中间使用半角逗号隔开-->  
  4.     <property name="basePackage" value="com.qianlv.ssmdemo.mapper" />  
  5.     <!--这里不用sqlSessionFactory是因为如果用会导致上面配置的dataSource失效-->  
  6.     <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />  
  7. </bean>  

但是在编辑一个Service中注入mapper会提示could not autowire,但是可以正常执行的。

[java] view plain copy
  1. public class ItemsServiceImpl implements com.qianlv.ssmdemo.service.ItemsService{  
  2.   
  3.     @Autowired  
  4.     ItemsMapperCustom itemsMapperCustom;  
  5.   
  6.     public List<ItemsCustom> findItemsList(ItemsQueryVo itemsQueryVo) throws Exception {  
  7.         return itemsMapperCustom.findItemsList(itemsQueryVo);  
  8.     }  
  9.   
  10. }  
我们需要改一下IDEA的设置

IDEA在编辑时提示could not autowire

将最右边的Serverity改为Warning

相关文章:

  • 2022-12-23
  • 2021-12-15
  • 2021-08-14
  • 2021-07-15
  • 2021-09-28
  • 2021-06-23
  • 2021-09-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
相关资源
相似解决方案