Mawia
Mawia

Reputation: 4310

What is ${some.thing} in XML configuration files for Java applications

I don't even know how to explain my confusion. I have seen this kind of format a lot in XML files for Java applications. It's very common in Spring framework.

    <bean class="my.class" >
        <property name="myVar" value="${some.thing}" />
    </bean>

I find this format also in many other Java applications without Spring.

  1. Does the symbol ${some.thing} has anything to do with Java?
  2. If not, is it just a tag/symbol which the XML parser understands?

Upvotes: 0

Views: 40

Answers (1)

Thilo
Thilo

Reputation: 262484

This is not an XML thing (and not a Java thing per se, either). The application code is interpreting it as an interpolation pattern and does substitution with values defined elsewhere.

But it is a very popular and useful thing to have. Many frameworks (like Ant, Maven, Spring) implement this, and not just for XML (also for properties files, for example).

Where exactly the values are coming from and where you can use interpolation depend on the tool in question.

Upvotes: 3

Related Questions