2

I have a bean that looks something like this:

<bean id="envUtil" class="com.environment.util.MainClass">
    <property name="config1" value="${var1}"></property>
    <property name="config2" value="${var2}"></property>
</bean>

Now I understand the class com.environment.util.MainClass gets initiated when the application shoots up.

But how does its data members config1 and config2 get their value?

What does the expression "${var1}" mean? And from where will this var be read?

I am new to Spring so please excuse me if the question is trivial.

Devon
  • 130
  • 10
Zeus
  • 149
  • 12
  • 1
    It represents a placeholder variable to be filled-in. See: https://www.baeldung.com/properties-with-spring#usage – Mr. Polywhirl Nov 25 '19 at 18:53
  • @Mr.Polywhirl From where will var1 be read ? – Zeus Nov 25 '19 at 18:54
  • Did you see the link above? It is coming from a properties file. This file can be declared in the XML or injected in via command line arguments. Look up examples of ``. – Mr. Polywhirl Nov 25 '19 at 18:56
  • It is basically SPeL https://docs.spring.io/spring/docs/4.2.x/spring-framework-reference/html/expressions.html – jmj Nov 25 '19 at 18:58
  • @Mr.Polywhirl It can come from anywhere that Spring can resolve it, which includes Spring Boot environment configuration and cloud resolvers like Vault or AWS Parameter Store. – chrylis -cautiouslyoptimistic- Nov 25 '19 at 19:03

0 Answers0