-1

For Spring Framework where is the complete list of reserved words or Predefined Variables about SpEL with their respective explanation? It such as for:

  • environment
  • systemProperties
  • systemEnvironment

For example in this valuable tutorial is just shown the 2 latest of the list shown above

Consider if Spring 6 added more of them, it as an improvement, therefore could be more.

Yes, I did do a research - currently for version 6 - at the official documentation at:

But does not contain the reserved words.

Note:

Yes, appears the getSystemEnvironment() and getSystemProperties() methods at the AbstractEnvironment class, but see the following class:

See the Field Summary section, it has the systemEnvironment and systemProperties variables used by SpEL. I am assuming other class would have the enviroment variable

Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
  • Is this what you're looking for? [expressions-beandef](https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#expressions-beandef) – Dirk Deyne Feb 15 '23 at 19:24
  • There, appear 2 of 3, same as [StandardEnvironment](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/env/StandardEnvironment.html) . wondered why does not appear `system`, it is used to retrieve the values of a `.properties` file through the `@Value` and `@PropertySource` – Manuel Jordan Feb 15 '23 at 20:19
  • btw, is **not** `system` - it does not exist - it is `environment` – Manuel Jordan Feb 15 '23 at 21:17

1 Answers1

1

There isn't really a list of reserved words for SpEL like what you are looking for, at least not in generic SpEL parsing and evaluation.

There is default SpEL support in the application context and notably in @Value annotations, as documented in the reference guide: Expressions in Bean Definitions.

Thi is provided via a SpEL StandardEvaluationContext which uses the beanFactory as the root object. Or rather, it uses a BeanExpressionContext view of the bean factory plus a dedicated PropertyAccessor is added to this evaluation context so that every beanName in the bean factory is considered a property of that root object during evaluation.

As a result, if a bean named foo is registered in the factory, @Value("#{ foo }") will be interpreted as "the property foo of the root object", which resolves to the aforementioned bean.

So systemProperties/systemEnvironment and environment are not really predefined SpEL variables, but rather standard beans in an AbstractApplicationContext.

Simon Baslé
  • 27,105
  • 5
  • 69
  • 70