change value in spring boot application using @RefreshScope to take effect during runtime

I have a spring boot application that reads a value from a property from file in the Spring Boot Application. I want to use it as a switch and need to be able to change it during run time so that the code will switch as per the value configured to get the desired output.

As of now it is requiring a restart of the application. Here is what I am using:

    public class MyServiceImpl implements MyService {

        private boolean SWITCH_ENABLED;

if (SWITCH_ENABLED==true) {
            // code for switch when true
        else {
            // code for switch is false

I have the following properties in the :


The value is not getting refreshed and takes effect only after restart. I tried using the spring-boot-actuator as well.