解决
从spring-boot文档中找到解决方法,很简单,SpringBootTest增加webEnvironment 参数。
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
package com.hengyun.admin;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class AdminApplicationTests {
@Test
public void contextLoads() {
}
}
作者:Tom 1988
来源:CSDN
原文:https://blog.csdn.net/xu_guo_jie/article/details/82979956
版权声明:本文为博主原创文章,转载请附上博文链接!