目录
一、问题描述
二、创建文件MyBatisConfig
三、或者直接
一、问题描述
Description:
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.
Action:
Consider defining a bean of type 'com.god.demo.app.dao.mapper.SysUserMapper' in your configuration.
Disconnected from the target VM, address: '127.0.0.1:63159', transport: 'socket'
说明:
com.god.emo.app.service.impl.SysUserServiceImpl中构造函数的参数0需要类型为“com.god.demo.app.dao.mapper.SysUserMapper”的bean,但找不到该bean。
操作:
考虑在配置中定义一个类型为“com.god.demo.app.dao.mapper.SysUserMapper”的bean。
已断开与目标VM的连接,地址:“127.0.0.1:63159”,传输:“socket”
二、创建文件MyBatisConfig
@MapperScan("com.xx.dao.mapper")
@Configuration
public class MyBatisConfig {
@Bean
public ConfigurationCustomizer configurationCustomizer() {
return configuration -> {
//驼峰命名法
configuration.setMapUnderscoreToCamelCase(true);
};
}
}
三、或者直接
@MapperScan("com.xx.dao.mapper")
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
有用请点赞,养成良好习惯!
疑问、交流、鼓励请留言!


发布评论