Currently, I am using below configuration my test classes-
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
@Transactional
As @TransactionConfiguration is deprecated, What can be the replacement for that-
I have tried -
@Transactional(transactionManager = "transactionManager")
@Commit
But I am getting the below error-
java.lang.IllegalStateException: Test class [ca.aeso.dt.dao.impl.AssetAttributeDaoImplTest] is annotated with both @Rollback and @TransactionConfiguration, but only one is permitted. at org.springframework.test.context.transaction.TransactionalTestExecutionListener.isDefaultRollback(TransactionalTestExecutionListener.java:383) at org.springframework.test.context.transaction.TransactionalTestExecutionListener.isRollback(TransactionalTestExecutionListener.java:412) at org.springframework.test.context.transaction.TransactionalTestExecutionListener.beforeTestMethod(TransactionalTestExecutionListener.java:201) at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:269)
Yes, @Commit is equivalent to setting the default rollback mode to false.
In addition, the default name for the transaction manager is "transactionManager". So you can just delete the declaration of the qualifier and use @Transactional on its own.
If the exception is complaining about the use of @TransactionConfiguration, then you must have it declared somewhere, either on the test class or on a superclass. The solution is to simply delete the complete @TransactionConfiguration declaration.
Regards,
Sam (author of the Spring TestContext Framework)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With