You can use it as implicit references defining an attribute or an argument in a method:
@Value("#{ systemProperties['user.region'] }") String defaultLocale; SpEL can access Spring beans:
@Value("#{beanId.method}") BeanType param; SpEL can access properties as Strings (casting may be needed):
@Value("${property1}") int property1; @Value("#{environment['property2']}") int property2; @Value("#{new Integer(environment['property3'])*2}") int property3; If undefined use : or ?: for SpEL to assign a default value:
@Value("${property1 : 1}") int property1; @Value("#{environment['property2'] ?: 1}") int property2;
Top comments (0)