XML property Spring configuration

Hello,

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">
            <list>
                <value>properties.xml</value>
            </list>
        </property>
    </bean>

Please help,

thnx in advance.

3 comments
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 3.7.2.1 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-->
<beans>
    <bean id="mappings" >
        <!-- typed as a java.util.Properties -->
        <property name="properties">
            <value>
                jdbc.driver.className=com.mysql.jdbc.Driver
                jdbc.url=jdbc:mysql://localhost:3306/mydb
            </value>
        </property>
    </bean>
</beans>


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

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

http://java.sun.com/dtd/properties.dtd">

<properties>

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

</properties>


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.

0
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

0

Please sign in to leave a comment.