SpringBoot整合其他框架

springBoot整合其他框架:

两类:

	1.以springBoot为主导,spring-boot-starter-XXX(junit)
	2.其他项目整合springboot,XXX-spring-boot-starter(mybatis)


SpringBoot整合junit:

导入依赖包(junit无需依赖包)

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>

配置(不需要)


代码

注解:@SpringBootTest,@Runwith

注意:如果测试类处于引导类所在目录或者所引导所在目录的子目录,不需要添加参数;如果不在,需要设置参数指定引导类



SpringBoot整合mybatis:

导入依赖包


配置

xml映射文件方式:

扫描映射文件所在包

实体类所在包别名扫描


注解开发:需要在Mapper接口添加@Mapper注解即可


代码



SpringBoot整合redis

导入依赖包

配置

redis连接配置见https://www.cnblogs.com/sanen/p/10069169.html

代码

RedisTemplate

原文地址:https://www.cnblogs.com/maomaodesu/p/12546001.html