spring-boot使用CodeGenerator自动创建mybatis

文章 , 技术分享
488 0

项目结构为这样

2023-05-07T12:29:25.png

修改包配置
2023-05-07T13:05:08.png

运行此文件
2023-05-07T12:29:25.png

按要求输入配置
2023-05-07T13:05:34.png

回车后就发现以及创建好了代码了
2023-05-07T13:08:09.png

修改扫描文件
2023-05-07T13:06:28.png

这里可以添加增删改查接口
2023-05-07T13:08:39.png

调用增加接口:
2023-05-07T13:10:08.png

如果报错显示,就是没添加scan
报错显示:

Error creating bean with name ‘userServiceImpl’: Unsatisfied dependency expressed through field ‘baseMapper’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.nanfangzhe.anpaipublic.mapper.UserMapper’ available: expected at least 1 bean which qualifies as autowire candidate.

在启动文件添加:

2023-05-04T12:20:38.png

添加时注意路径

@MapperScan(“com.atguigu.mybatis_plus.mapper”)

最后更新 2023-07-16
评论 ( 0 )
OωO
隐私评论