DKS
DKS

Reputation: 315

Spring boot, Update/override application.properties value programatically/dynamically (JAVA)

I am using Spring boot. Application uses JWT token(another micro service) for authentication. I have to implement caching of JWT token. I am using Caffeine Cache.

Problem: Now the problem is this token expiry time is always dynamic and i have to match token expiry time with Cache expiry time. i.e.

Cache expiry time <= Token expiry time

Question: Is there any way to achieve this using Spring Cache?

Can we set value of below property dynamically, depends on JWT token expiry time?

spring.cache.caffeine.spec=expireAfterWrite=600s

Upvotes: 0

Views: 602

Answers (1)

Aakash Sorathiya
Aakash Sorathiya

Reputation: 11

You can use System.setProperty() to change the value of environment variable from code.

Upvotes: 0

Related Questions