How to enable properties substitution in spring config files

Answered

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.

 

3 comments
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 https://maven.apache.org/plugins/maven-resources-plugin/examples/resource-directory.html may help.

0
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?

0
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 https://youtrack.jetbrains.com/issues/IDEA with a sample project to reproduce.

0

Please sign in to leave a comment.