引入依賴
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.4</version>
</dependency>
<!-- sqlServer依賴 -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<scope>runtime</scope>
</dependency>
Application.java文件中設置包掃描路徑
@SpringBootApplication
@MapperScan(basePackages = "com.xiaoge.mybatis_demo.dao")
public class MybatisDemoApplication {
public static void main(String[] args) {
SpringApplication.run(MybatisDemoApplication.class, args);
}
}
Application.yml文件中設置mapper路徑
mybatis:
mapper-locations: classpath:mapper/*.xml
使用Mybatis生成插件生成常用代碼
![在這裏插入圖片描述]()