Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6081655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:12:01+00:00 2026-05-23T11:12:01+00:00

Typical XML for hooking up a transaction manager in Spring looks like: <bean id=txManager

  • 0

Typical XML for hooking up a transaction manager in Spring looks like:

<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="myDataSource" />
</bean>

<bean id="myDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    .... properties go here ....
</bean>

How do I accomplish the same thing with code?

@Configuration
public class MyConfig {
  @Bean
  public DataSource myDataSource() {
       return new DataSource(); /// and set properties, etc.
  }

  @Bean
  public DataSourceTransactionManager txManager() {
       --> What goes here? <--
  }
}

Specifically, how do I get txManager wired up to the myDataSource singleton via code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:12:02+00:00Added an answer on May 23, 2026 at 11:12 am

    Since DataSourceTransactionManager has a constructor that takes DataSource, you can do the following (otherwise you would need to call setDataSource()):

    @Bean   
    public DataSourceTransactionManager txManager() {
        return new DataSourceTransactionManager(myDataSource());
    }
    

    See also:

    • 3.11.4.2 Injecting dependencies
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a Hibernate/Spring application that have the following Spring beans: <bean id=transactionManager class=org.springframework.orm.hibernate3.HibernateTransactionManager
The typical ConfigParser generated file looks like: [Section] bar=foo [Section 2] bar2= baz Now,
it looks like I'm facing a typical memory outage problem when using a PHP
Typical way of creating a CSV string (pseudocode): Create a CSV container object (like
A typical approach to avoid two instances of the same script running simultaneously looks
I have a typical pom.xml, and want to print the groupId, artifactId and version,
I have a typical GWT app, in my module.xml, I have, <inherits name='com.google.gwt.user.theme.standard.Standard' />
For example, the prxml function prints XML to *out*. I would like to instead
I want to assemble a web module which looks like the following: src/main/java (has
I've a table with a typed XML field. Typical XML format is: <root> <users>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.