Springboot默认集成事物,只主要在方法上加上@Transactional即可
出现以下错误
No qualifying bean of type [javax.sql.DataSource] is defined: expected single matching bean but found 2: test1DataSource,test2DataSource
加上@Primary即可。
出现以下错误:
There was an unexpected error (type=Internal Server Error, status=500).
No qualifying bean of type 'org.springframework.transaction.PlatformTransactionManager' available: expected single matching bean but found 2: test1TransactionManager,test2TransactionManager
解决:指定事务管理器
Springboot1.5的时候 没有默认指向数据源 会报错
Springboot2.0的时候 不报错