Announcement Announcement Module
Collapse
No announcement yet.
propertyConfigurer doesn't work out of web context Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • propertyConfigurer doesn't work out of web context

    This is part of my applicationContext.xml:

    Code:
     <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:archery.properties</value>
                </list> 
            </property>
        </bean>
        
        <bean id="dataSource"
            class="org.apache.commons.dbcp.BasicDataSource"
            destroy-method="close">
            <property name="driverClassName">
                <value>${database.driverClassName}</value>
            </property>
            <property name="url">
                <value>${database.url}</value>
            </property>
            <property name="username">
                <value>${database.username}</value>
            </property>
            <property name="password">
                <value>${database.password}</value>
            </property>
        </bean>
    Everything works well in a web environment, but fails to replace ${..} elements out of it.
    I am using JUnit to test some parts of my application and I can't use it with this configuration.
    What is wrong?

    Thanks

  • #2
    Probably when not inside a web environment the Propertyplaceholder fails to find the files and has no values to replace the aliases.

    Comment


    • #3
      Originally posted by costin
      Probably when not inside a web environment the Propertyplaceholder fails to find the files and has no values to replace the aliases.
      Really strange...
      I thought it was obviuos that who works with Spring do it also because it shuold keep a consistent configuration between testing and real environment.

      Comment


      • #4
        I assume most people have the same configuration files but it your job to have the same structure between the local and real environment. They usually differ and you have to use separate configuration files.

        Comment

        Working...
        X