Spring Boot如何测试打包部署
一、开发阶段 (一)单元测试 在开发阶段的时候最重要的是单元测试,Spring Boot对单元测试的支持已经很完善了。 1、在pom.xml文件中添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> 2、开发测试类 以最简单的helloworld为例,在测试类的类头部需要添加:@RunWith(SpringRunner.class)和@SpringBootTest注解,在测试方法的顶端添加@Test即可,最后在方法上点击右键run就可以运行了。 @RunWith(SpringRunner.class) @SpringBootTest public class ApplicationTests { @Test public void hello...