Another unnamed CacheManager already exists in the same VM (ehCache 2.5)

前端 未结 17 1942
囚心锁ツ
囚心锁ツ 2020-11-30 20:41

This is what happens when I run my junit tests...

Another CacheManager with same name \'cacheManager\' already exists in the same VM. Please 
provide unique          


        
17条回答
  •  一整个雨季
    2020-11-30 21:09

    Your problem is the context loading optimization built in the Spring test framework. Spring (per default) does not destroy the context once the test class is done, in hope that another test class might reuse it (instead of creating it from scratch).

    You can override this default using @DirtiesContext, or if you use maven you can set surefire forkMode to "always" and create a new VM per test class.

提交回复
热议问题