Results 1 to 2 of 2

Thread: only one PropertyPlacholderConfigurer?

  1. #1
    Join Date
    Oct 2004
    Location
    San Diego, CA USA
    Posts
    58

    Question only one PropertyPlacholderConfigurer?

    I have several different modules packaged in jars, where each has its own Spring config and its own PropertyPlaceholderConfigurer, declared via the context namespace. I then have an integration test that is loading all the application contexts via the classpath. It appears that only one (the last? the first?) PropertyPlaceholderConfigurer is found.

    Specifically:

    module1-context.xml
    Code:
    <context:property-placeholder system-properties-mode = "OVERRIDE" location = "classpath:module1.properties"/>
    module2-context.xml
    Code:
    <context:property-placeholder system-properties-mode = "OVERRIDE" location = "classpath:module2.properties"/>
    module3-context.xml
    Code:
    <context:property-placeholder system-properties-mode = "OVERRIDE" location = "classpath:module3.properties"/>
    integration test:
    Code:
    @ContextConfiguration({"classpath:main.xml", "classpath*:*-context.xml"})
    public class MyTest extends AbstractJUnit4SpringContextTests {
    when I run the test, it loads properties from one of the modules, but fails to load the others.

    I see debug log messages that the beans were found, but only one log message from PropertyPlaceholderConfigurer itself that it's loaded the properties file.

    Code:
    15:13:04,176 [main]        DEBUG o.s.c.s.GenericApplicationContext - Bean factory for org.springframework.context.support.GenericApplicationContext@148238f4: org.springframework.beans.factory.support.DefaultListableBeanFactory@1c23f1bb: defining beans [...,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,...]
    <snip>
    15:13:04,556 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0'
    15:13:04,557 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0'
    15:13:04,559 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0' to allow for resolving potential circular references
    15:13:04,599 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0'
    15:13:04,600 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#1'
    15:13:04,601 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#1'
    15:13:04,601 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#1' to allow for resolving potential circular references
    15:13:04,602 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#1'
    15:13:04,603 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#2'
    15:13:04,603 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#2'
    15:13:04,603 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#2' to allow for resolving potential circular references
    15:13:04,604 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#2'
    15:13:04,605 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#3'
    15:13:04,605 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#3'
    15:13:04,605 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#3' to allow for resolving potential circular references
    15:13:04,607 [main]        DEBUG o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#3'
    15:13:04,607 [main]        INFO  o.s.b.f.c.PropertyPlaceholderConfigurer - Loading properties file from class path resource [module1.properties]
    any thoughts? this is Spring 3.0.5.

  2. #2
    Join Date
    Oct 2004
    Location
    San Diego, CA USA
    Posts
    58

    Default

    My bad (of course) ... forgot to add ignore-unresolvable = "true" so that as Spring iterates over each PropertyPlaceholderConfigurer if the current one can't find the property it won't fail, but rather let Spring move on to the next one.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •