Python 官方文档:入门教程 => 点击学习
目录整合JunitSpringBoot整合mybatis整合Junit 在Boot环境下如何进行单元测设 注解:@springBootTest类型:测试类注解位置:测试类上方作用:设
在Boot环境下如何进行单元测设
例:
@SpringBootTest(classes = Springboot07JunitApplication.class)
class Springboot07TestApplicationTests {}
相关属性
classes:设置SpringBoot启动类
注:如果测试类在SpringBoot启动类的包或者子包中,可以省略启动类设置,也就是省略classes的设定。
import com.ityc.service.BookService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class Springboot07TestApplicationTests {
@Autowired
private BookService bookService;
@Test
public void testService() {
bookService.save();
}
}
serverTimezone=UTC一定记得设置时区,否则idea会爆连接数据库错误,让人以为是密码错了!!!
spring:
datasource:
driver-class-name: com.Mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/SSM_db?serverTimezone=UTC
username: root
passWord: lyc
type: com.alibaba.druid.pool.DruidDataSource
@Mapper
public interface BookDao {
@Select("select * from tbl_book where id = #{id}")
public Book getById(Integer id);
}
测试
@SpringBootTest
class Springboot08MybatisApplicationTests {
@Autowired
private BookDao bookDao;
@Test
void testGetById() {
Book book = bookDao.getById(10);
System.out.println(book);
}
}
到此这篇关于SpringBoot整合第三方技术的实现的文章就介绍到这了,更多相关SpringBoot整合第三方内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: SpringBoot整合第三方技术的实现
本文链接: https://www.lsjlt.com/news/194282.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0