闲谈
很遗憾,事与愿违,关于Spring-Boot整合Mybaits的文章就不出来,需要的朋友可以加java群:238132240。里面有Spring-Boot整合Mybaits的Demo,有事务,整合了通用Mapper,分页工具pageHelper.
正篇
spring-boot如何进行单元格测试?想必是一个很重要的环节,在Spring传统项目中,使用单元格测试不言而喻。这里分别介绍从MVC分层的思想分别进行阐述:
Spring-Boot需要的maven依赖:
<!-- spring boot test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
会自动添加junit和spring-testjar。
dao层
示例代码:
package dao;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4