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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章