XML property Spring configuration


I'm using EAP build and I have a Spring application and XML properties file.

I want to use properties from my xml file in Spring context configuration.

Everythng works fine, but in my context.xml I have red markers for ${somePropery}, that are defined in XML property file.

This is how I init my properies:

<bean id="propertyConfigurer" >
        <property name="locations">

Please help,

thnx in advance.

Comment actions Permalink

I'm not a Srping guru, but know my way around it okay. So I may not be aware of something... but I am not sure what you mean by a "XML properties file". XML and properties are too different file formats. Did you mean an "XML placeholders file"? Currently, you are defining a PropertyPlaceholderConfigurer but passing in an XML file for a value. Per section of the Spring 2.5.6 reference document:

The PropertyPlaceholderConfigurer is used to externalize property values from a BeanFactory definition, into another separate file in the standard Java Properties format.

The JavaDoc for PropertyPlaceholderConfigurer makes similar statements. So I am not seeing any indication that you can pass in an XML file. If you change that file to an actual properties file, that should resolve your issue.

If you are, for some reason, wanting to use bean markup to deifne your properties in a separate file, for example:

<!-- namespaces removed for brevity-->
    <bean id="mappings" >
        <!-- typed as a java.util.Properties -->
        <property name="properties">

Then in your main context file, you would use an <import> to load that and not a PropertyPlaceholderConfigurer.

Comment actions Permalink

Actually it is standard to specify properties in both XML and plain text formats.

I'm using XML style:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE properties SYSTEM "



<entry key="prop">propValue</entry>


So, no controverse with stated in javadoc.

And this functionality works fine.

What bugs me is properties marked red in my context xml file.

This is just not right.

Comment actions Permalink

Ah... I forgot about that XML version of properties files. IDEA may just not recognize it. I'd suggest opening a feature request for it: http://youtrack.jetbrains.net/issues


Please sign in to leave a comment.