I found that Mockbean is work the test main thread, but not work in the new thread call, following is my demo code. call the mock first time in new thread is work, but when call the demoService in second times, it return null (mock not work)
Comment From: stoneZ008
Reference Jar Version mockito-core 4.11.0 JDK1.8 Junit4 SpringBoot: 1.5.22.RELEASE
Comment From: wilkinsona
Spring Boot 1.5.x hasn't been supported since August 2019. Please upgrade to Spring Boot 2.7.x or later. If the problem still occurs, please provide an updated demo project and we can take a look.
Comment From: stoneZ008
after upgrade to 2.7.12 , the issue is slove
Comment From: wilkinsona
Thanks for letting us know.