@SpringBootApplication
@MapperScan("com.tx.dao")
public class SdkApiApplication {
public static void main(String[] args) {
SpringApplication.run(SdkApiApplication.class,args);
}
}
public interface UserMapper extends BaseMapper<User> {
/**
* 查询所有用户信息
* @return list
*/
List<User> selectAll();
}
https://www.jianshu.com/p/12ec123d20e8
mybatis:
mapper-locations: mapper/*.xml
global-config:
db-config:
# 主键策略
id-type: auto
# 表名前缀
table-prefix: t
# 表名是否使用下划线间隔,默认:是
table-underline: true
# 添加mybatis配置文件路径
config-location: mybatis-config.xml
# 配置实体类包地址
type-aliases-package: com.tx.pojo
# 驼峰转下划线
configuration:
map-underscore-to-camel-case: true
依赖pom文件
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<!-- mysql驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.41</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.1.2</version>
</dependency>
spring boot集成mybatis-plus遇到的坑
问题:
rg.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userMapper' defined in fil
--------------------------------------
不能创建这个bean,最基本的这个baseMapper'报错
解决如下:
mybatis-plus 修改为 mybatis
mybatis-plus 修改为 mybatis
mybatis-plus 修改为 mybatis
mybatis:
mapper-locations: mapper/*.xml
global-config:
db-config:
# 主键策略
id-type: auto
# 表名前缀
table-prefix: t
# 表名是否使用下划线间隔,默认:是
table-underline: true
# 添加mybatis配置文件路径
config-location: mybatis-config.xml
# 配置实体类包地址
type-aliases-package: com.tx.pojo
# 驼峰转下划线
configuration:
map-underscore-to-camel-case: true
参考文章如下:https://blog.csdn.net/qq_21747795/article/details/81217264