Consider defining a bean of type ‘com....mapper.SysUserMapper‘ in your configuration.

逃离我推掉我的手 2022-11-29 12:21 304阅读 0赞







springboot项目创建常见问题(建议收藏!!) https://blog.csdn.net/libusi001/article/details/97267365

一、问题描述

  1. Description:
  2. Parameter 0 of constructor in com.god.demo.app.service.impl.SysUserServiceImpl required a bean of type 'com.god.demo.app.dao.mapper.SysUserMapper' that could not be found.
  3. Action:
  4. Consider defining a bean of type 'com.god.demo.app.dao.mapper.SysUserMapper' in your configuration.
  5. Disconnected from the target VM, address: '127.0.0.1:63159', transport: 'socket'

二、创建文件MyBatisConfig

  1. @MapperScan("com.xx.dao.mapper")
  2. @Configuration
  3. public class MyBatisConfig {
  4. @Bean
  5. public ConfigurationCustomizer configurationCustomizer() {
  6. return configuration -> {
  7. //驼峰命名法
  8. configuration.setMapUnderscoreToCamelCase(true);
  9. };
  10. }
  11. }

三、或者直接

  1. @MapperScan("com.xx.dao.mapper")
  2. @SpringBootApplication
  3. public class DemoApplication {
  4. public static void main(String[] args) {
  5. SpringApplication.run(DemoApplication.class, args);
  6. }
  7. }

发表评论

表情:
评论列表 (有 0 条评论,304人围观)

还没有评论,来说两句吧...

相关阅读