Announcement Announcement Module
Collapse
No announcement yet.
Issue for Datasource Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issue for Datasource

    Hello
    i have a question about initializing DataSource. proj's config is liike below.

    <bean id="sfwTransactionManagerCO" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager" >
    <property name="dataSource" ref="sfwCODataSource" />
    <qualifier value="sfwTransactionManagerCO" />
    </bean>

    <bean id="sfwTransactionManagerLN" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager" >
    <property name="dataSource" ref="sfwLNDataSource" />
    <qualifier value="sfwTransactionManagerLN" />
    </bean>

    in project environment, two transaction managers are defined in xml.
    but actually, the project is used only one.
    but in the project, only one is is used(sfwTransactionManagerCO is autowired in a object). so i think the container should create one transactionManager. but the other is created too.
    how to change the way bean is initialized when is autowired in objects ?

  • #2
    Just a bit curious -- if you don't want to use the second transaction manager, why do you define it?

    If the answer is that in some environments/deployments you want to use one, and in others you want to use the other, it seems to me that the best approach is to use Spring's "profiles" facility. Here's a blog article which introduces the subject.

    Or you could try setting the "lazy-init" property of the one you don't want to have pre-instantiated to "true". But I think the use of profiles is a better way to approach this.

    Comment

    Working...
    X