gpt4 book ai didi

Spring shell block 测试

转载 作者:行者123 更新时间:2023-12-05 02:08:56 25 4
gpt4 key购买 nike

当我在项目中添加spring shell时

    <dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell-starter</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>

测试开始挂起并且永不结束。停止后我在日志中看到

2020-02-22 20:00:14.271  INFO 9812 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'taskScheduler'
2020-02-22 20:00:14.933 WARN 9812 --- [ main] org.jline : Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
2020-02-22 20:00:15.229 INFO 9812 --- [ main] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [192.168.1.10:5672]
2020-02-22 20:00:15.312 INFO 9812 --- [ main] o.s.a.r.c.CachingConnectionFactory : Created new connection: rabbitConnectionFactory#4c32d208:0/SimpleConnection@608c36a6 [delegate=amqp://admin@192.168.1.10:5672/, localPort= 65404]
2020-02-22 20:00:15.401 INFO 9812 --- [ main] c.umbrella.app.BackendApplicationTests : Started BackendApplicationTests in 12.969 seconds (JVM running for 14.251)

Process finished with exit code -1
shell:>

当我从 IDE 和 mvn 运行测试时,问题重现。如何避免测试出现问题?

最佳答案

我找到了解决方案,它需要为每个测试添加下一个属性:

@SpringBootTest(properties = {
InteractiveShellApplicationRunner.SPRING_SHELL_INTERACTIVE_ENABLED + "=false",
ScriptShellApplicationRunner.SPRING_SHELL_SCRIPT_ENABLED + "=false"
})

关于Spring shell block 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60352443/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com