Announcement Announcement Module
No announcement yet.
Loading Spring context files form jars Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loading Spring context files form jars


    In my project I have the following situation: we are several partners and each partner will develop a component. Each partner will have his own database so each partner will define his own datasourse, sqlsessionfactory (we are using mybatis), transactionmanager etc....
    Moreover each partner will have his own configuration file (a .properties file) loaded by using the org.springframework.beans.factory.config.PropertyP laceholderConfigurer

    Each component will be a JAR in the web-inf/lib directory

    Now I saw the following: partner A and partner B developed two simple components. By doing their own tests (partner A for the component A and partner B for component B) all worked pretty good
    When I tried to test the two components under the main web-app I noticed that only one properties file has been loaded so one component worked and the other one didn't work.

    Is there a way in orther to load all the properties file from different jars? (Note that I don't know the properties file names)
    Moreover I told partners to use unique ids for bean definition in order to avoid the bean overriding (for example the datasource bean for partner A should have this id: dataSourceA while the datasource bean for partner B should have this id: dataSourceB and so on....). Is this approach good and valid?
    Was anybody in this situation? Do you have any kind of suggestion?

    Thank you so much

  • #2
    Any sugestion/idea?

    Thank you


    • #3
      As long as you put your component jars in the classpath, and the property file is visible from your PropertyPlaceholderConfigurer and no naming conflict, everything should work. If you have a common propertyConfigurer, you can do something like this:

      <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
              <property name="locations">
      in your case, you may have, and for component A and component B.
      Last edited by tannoy; Sep 8th, 2012, 06:26 PM.