如何把mybatis-plus的MapperScan注解替换为mybatis的MapperScan注解
时间: 2023-07-28 21:38:42 浏览: 135
将MybatisPlus的MapperScan注解替换为Mybatis的MapperScan注解,需要进行以下步骤:
1. 找到MybatisPlus的MapperScan注解,通常是在启动类上或者配置类上。
2. 将MybatisPlus的MapperScan注解替换为Mybatis的MapperScan注解。
3. 将MybatisPlus的MapperScan注解中的basePackages属性替换为Mybatis的basePackage属性,指向Mybatis的Mapper接口所在的包路径。
例如,假设原来的MybatisPlus的MapperScan注解配置如下:
```java
@SpringBootApplication
@MapperScan("com.example.demo.mapper")
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
```
将其替换为Mybatis的MapperScan注解,代码如下:
```java
@SpringBootApplication
@org.mybatis.spring.annotation.MapperScan(basePackages = "com.example.demo.mapper")
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
```
需要注意的是,Mybatis的MapperScan注解需要使用org.mybatis.spring.annotation.MapperScan类,而不是使用MybatisPlus的MapperScan类。
阅读全文
相关推荐


















