1

I'm trying to use a Spring JdbcTemplate instance to generate a DataSet useable for subsequent DBUnit tests.

any ideas how to do that?

all the documentation I found where going from a JDBC Connection instance to a IDatabaseConnection instance.

But the code I have abstract all this away using Spring, and what I have is a JdbcTemplate instance.

Any ideas?

4

1 回答 1

3

您的 jdbcTemplate bean 有一个 dataSource 属性,因此您可以使用它的 getter 从 jdbcTemplate 获取它,或者在您构建 IDatabaseConnection 的类中注入 dataSource(您已经在 applicationContext 中的某处定义)并将其用作构造函数-为此 arg。(你应该做后者)

详细解释和完整示例请参见以下博客(由 springsource 培训师编写)

于 2011-05-13T20:55:52.127 回答