edit: please pay close attention to the question. I want to make changes without having to rebuild and redeploy the application. I want to make changes on the fly.
I have a simple Spring boot application where I am trying to test if an application can read environment variable without having to rebuild and redeploy the application.
I have a simple main class which is also a @RestController
@SpringBootApplication
@RestController
@EnableScheduling
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Value("${taco.orders.pageSize}")
private String pageSize;
@GetMapping("/myName")
public String myName() {
return pageSize;
}
int i = 0;
@Scheduled(fixedRate = 2000L)
public void scheduled() {
System.err.println(++i + "-" + pageSize);
}
}
This is what I have in my application.yml file:
taco:
orders:
pageSize: fifty
This print fine "fifty". But when I go to terminal and set a different value for the key, that new value is not reflected.
export TACO_ORDERS_PAGESIZE=NINETY
I have also created a git repo if somebody wants to retry it.