How to enable properties substitution in spring config files


IDE replaces the property in the spring config files by value from src/main/resources.

What if property files are located on the same with src folder? Is there a way to attach or replace "src/main/resources" with another folder?

Thanks in advance.


Comment actions Permalink

Resources should appear in the target application classpath, it doesn't matter from what directory they are copied there, however the resource copy rules can be defined by your project (like Maven).

If you want to copy resources from non-standard locations, you probably need to adjust your project configuration.

Hard to tell more without your project details, but may help.

Comment actions Permalink

Thank you for your fast reply!

Seems like I didn't make myself clear...

I was trying to say that: there are Spring config files and there are property files. Idea has a nice feature: it replaces placeholders in config files by corresponding values from properties.
Like here, for example:

was written something like <property name="exclusive" value=${rabbitmq.exclusive} />

And there were also following lines in the properties file:
#exclusive - true if we are declaring an exclusive queue
rabbitmq.exclusive = true

And once it was replaced by IDE, it became like on the screenshot above.

But this feature works only for properties located in the "src/main/resources" folder.

Is there a way to specify another folder?

Comment actions Permalink

It should work for any directory from where resources are copied to classpath. If it doesn't work for you in IDEA, but properties work fine in the target app, please submit a bug at with a sample project to reproduce.


Please sign in to leave a comment.