dragonfly
dragonfly

Reputation: 17773

Properties file with Spring - how to use them

I have a properties file sample.properties put in project's root resource folder with this content:

auditorium.name=New York.

Now in spring.xml I try to access some of them with following syntax:

<bean id="auditorium1" class="hometask.domain.Auditorium">
    <property name="name" value="${auditorium.name}" />
</bean>

But in run-time this property is not resolved. name is set to string ${auditorium.name} instead of New York.

Is there anything else I should set up to have it working?

Upvotes: 0

Views: 33

Answers (1)

Rafik BELDI
Rafik BELDI

Reputation: 4158

you should set-up the placeholder of your properties this way:

<context:property-placeholder location="classpath:sample.properties"/>

Upvotes: 2

Related Questions