I try to pass a number value from the Spring properties file to Annotation long properties and I wonder how to set correctly non-string parameter. I try to use the following way, and obviously, we cant define parameters with strings because of Incompatible types. Found: 'java.lang.String', required: 'long'
And my question is "How to pass a number parameter from a properties file to a Spring annotation number parameter"
application.properties
my.parameter=10
MyAnnotation.java
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface MyAnnotation {
long myParameter() default 0;
}
MyClass.java
@Component
@MyAnnotation(myParameter = "${my.parameter}") //incompatible types long and String
public class MyClass {
//some code
}