1

I am trying to access a value from application.properties in RestControllerAdvice file. The value is not getting read as the advice bean loads first i guess. Is there any way to bring in the value from application.properties file into advice file.

@Value annotation reads null from application.properties in advice controller.

inkredusk
  • 919
  • 4
  • 16
  • Does [this](https://stackoverflow.com/a/30528430/19835740) or [this](https://stackoverflow.com/a/38314645/19835740) answer your question ? Also please add example of what you tried. – Daxelarne Apr 06 '23 at 10:03
  • 1
    There is far too little information here. If the `@Value` isn't resolved and you don't get an error upon startup (that it cannot resolve the value) means your class isn't controlled by Spring. – M. Deinum Apr 06 '23 at 10:06

1 Answers1

0

Try it

For example:

In application.properties file:

expired.time=1440

In any file, import:

import org.springframework.beans.factory.annotation.Value;

...

public class AnyClass {

    @Value("${expired.time}")
    private Integer expiredTime;

}