在SpringBoot开发中遇到的小问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_36634753/article/details/85616500

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的,把文件名修改成其它就行了

猜你喜欢

转载自blog.csdn.net/weixin_36634753/article/details/85616500
今日推荐