Spring Boot - How to disable @Cacheable during development?

前端 未结 3 467
一生所求
一生所求 2020-12-14 08:07

I\'m looking for 2 things:

  1. How to disable all caching during development with Spring boot \"dev\" profile. There doesn\'t seam to be a general setting to tu

3条回答
  •  时光说笑
    2020-12-14 08:21

    For your second question do something like this:

    Write a method that determines whether or not a particular profile is active (environment is your injected Environment)

    boolean isProfileActive(String profile) { 
       return Arrays.asList(environment.getActiveProfiles()).contains(profile);
    }
    

    then use that for your spel condition on the cacheable annotation

提交回复
热议问题