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的時候 不報錯