SpringBoot整合事物管理

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

 

發佈了31 篇原創文章 · 獲贊 1 · 訪問量 6528
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章