1、引入依赖
<!-- mybatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.4</version>
</dependency>
2、配置参数
我这里没有将Mapper写在Resource中,而是写在与Mapper同级的位置。所以会报Invalid bound statement (not found)
mybatis:
mapper-locations: com/luff/ucenter/dao/*.xml
type-aliases-package: com.luff.framework.domain #扫描本包下所有实体并用此类的名字建立别名
3、配置资源路径(解决方案)
将java源文件路径配置成资源文件路径
<build>
<!--这个元素描述了项目相关的所有资源路径列表,例如和项目相关的属性文件,这些资源被包含在最终的打包文件里。-->
<resources>
<resource>
<!-- 描述存放资源的目录,该路径相对POM路径-->
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
4、拿捏