介绍
今天就跟大家聊聊有关在SpringBoot中如何使用MongoDb实现单元测试功能,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
先引入pom依赖
& lt; dependency> & lt; groupId> org.springframework.boot & lt; artifactId> spring-boot-starter-test & lt; scope> test & lt;/dependency>
代码1
@RunWith (SpringRunner.class) @SpringBootTest @ transactional 公开课ApplicationTests { @ autowired 私人RedisService RedisService; @ autowired 私人UserDao UserDao; @ autowired 私人JdbcTemplate JdbcTemplate; @ autowired 私人MongoTemplate MongoTemplate; @Test 公共空间hello () { System.out.println(“你好world"); redisService.setObjectJSON (“test",“1“); System.out.println(“使用了redisservice"); 用户用户=userDao.find (“id=, # 63;“, 1 l)当代(); System.out.println(“打印出了一个用户名“+ user.userName); List
看完上述内容,你们对在SpringBoot中如何使用MongoDb实现单元测试功能有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。