bobah
bobah

Reputation: 18864

spring property placeholder with custom prefix in resource attribute of import element

I need to be able to say <import resource="context-@{subname}.xml" />. Can I do it with Spring 3.1.2.

Upvotes: 0

Views: 370

Answers (1)

MattSenter
MattSenter

Reputation: 3120

You could certainly use SpEL to pull in your "subname" from, for example, your environment:

<import resource="context-#{environment['subname']?:'somedefault'}.xml" />

However, if you're doing that, you should probably be pulling all of your settings in from your environment (System Properties and System Environment) instead, but if you really need to do different xml files based on environment, perhaps you should instead take a look Spring's Profiles to separate your configurations into logical groups:

http://java.dzone.com/articles/using-spring-profiles-xml

Upvotes: 1

Related Questions