Configure and Use Multiple DataSources in Spring Boot
tweetysat opened this issue · comments
The code is working fine.
But if I want to use the TodoRepository
inside a service class with a transactional annotation on the method
@Service
public class DataService {
...
@Transactional
public void test() {
totoRepository.findAll();
}
...
}
It it not working anymore, telling me something like
No qualifying bean of type 'org.springframework.transaction.TransactionManager' available: expected single matching bean but found 2: todosTransactionManager,topicsTransactionManager
If I try to change with @Transactional(value = "todosTransactionManager")
the application don't start and the todosTransactionManager
is causing java: incompatible types: java.lang.String cannot be converted to jakarta.transaction.Transactional.TxType
How to resolve that ?
My mistake...
I had to import org.springframework.transaction.annotation.Transactional
and not jakarta.transaction.Transactional
.
Now it's working.