org.h2.jdbc.jdbcsqlexception: database is already closed (to disable automatic closing at vm shutdown, add ";db_close_on_exit=false" to the db url) [90121-197]

org.h2.jdbc.jdbcsqlexception: database is already closed (to disable automatic closing at vm shutdown, add ";db_close_on_exit=false" to the db url) [90121-197]

在集成测试的时候遇到这个问题,后来发现,测试代码采用异步调用,而被测试的接口是同步的,这样就会导致超时。最好不要用这种方式,但是没办法,要统一改的话,工作量会比较大,而且任务比较紧,一个偷懒的办法就是,将超时时间设置的长一些,
在集成测试项目文件中添加如下代码

@Autowired
protected WebTestClient http;

/**
* 设置超时时间.
*/
@Before
public void setUp() {
http = http
.mutate()
.responseTimeout(Duration.ofMillis(100000))
.build();
}

猜你喜欢

转载自www.cnblogs.com/lijinping321/p/10275802.html