【发布时间】:2016-01-29 22:37:34
【问题描述】:
为了正确看待事情,一切正常,直到我不得不格式化我的工作站。在我设法让项目运行之后,我运行了 JUnit 测试并且我的大部分测试都失败了。问题是因为数据库没有回滚。也许我错过了一些配置,也许是 mysql 它自己。
所以,这些是我的配置/源文件:
一个 JUnit 类声明:
@ContextConfiguration(locations = { "classpath*:testApplicationContext.xml" })
@RunWith(SpringJUnit4ClassRunner.class)
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
@Transactional
public class ClientServiceTest {
测试范围的applicationContext:
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${user}"/>
<property name="password" value="${password}"/>
<property name="defaultAutoCommit" value="false" />
</bean>
【问题讨论】: