Does Springboot @RefreshScope work with records

40 views Asked by At

I am building an application with java 21 and Springboot. I have added the Springcloud config and actuator dependencies. I was wondering if I can use Java records with to refresh the configuration like I do with classes?

@ConfigurationProperties(prefix = "remote.file")
@RefreshScope
public record Fileproperties( String nfsnameing path  ) { }
1

There are 1 answers

5
Mohamed amine ben hassen On

Yes you still can do that with java 21

@Component
@ConfigurationProperties(prefix = "remote.file")
@RefreshScope
public record FileProperties(String path) { }