spring transaction template NoUniqueBeanDefinitionException

0 Background introduction

Two data sources are used in the project and two transaction templates are opened.

1 error protection information

org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type ‘org.springframework.transaction.support.TransactionTemplate’ available: expected single matching bean but found 2: secondTransactionTemplate ,thereTransactionTemplate

2 solutions

    @Autowired
    private TransactionTemplate secondTransactionTemplate;

    @Resource(name = "thereTransactionTemplate")
    private TransactionTemplate thereTransactionTemplate;

Use @Resource to specify.

Guess you like

Origin blog.csdn.net/qq_39463175/article/details/132288152