在SpringBoot开发中遇到的小问题

1、Field menuDao in com.example.operationplatform.service.impl.MenuServiceImpl required a bean of type 'com.example.operationplatform.dao.MenuDao' that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'com.example.operationplatform.dao.MenuDao' in your configuration.

解决方法:在启动类上添加注解MapperScan,把DAO层扫描进来

@MapperScan("com.example.operationplatform.dao")

2、org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.operationplatform.dao.MenuDao.findMenuByAdminId

如果你的mapper文件写的都对,任然找不到,那可能是你没有配置mapper文件地址

解决方法:在application.properties文件中添加mapper文件地址

mybatis.mapperLocations = classpath:mapper/*.xml

3、启动SpringBoot项目的时候 ,使用@ImportResource(“application.xml”)如出现如下异常

文档根元素 "beans" 必须匹配 DOCTYPE 根 "null"
原因是在文件命名上出的问题,springboot本身占用了这个名字,是不能取名为application.xml的,把文件名修改成其它就行了

  • 9
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值