JavaEar 专注于收集分享传播有价值的技术资料

What to use instead of SimpleJdbcTestUtils?

I am trying to set up a database test using Spring and DBUnit. I have a script to run before each test. The code below works but SimpleJdbcTemplate is deprecated. The method executeSqlScript is being moved to JdbcTestUtil as part of the 3.2 release but we're on 3.1.x. What to use instead?

public class MyTestScript{

    public DataSource dataSource;
    public Resource script;

    public void setup() {
            new SimpleJdbcTemplate(dataSource), script, true);

    public void testInsert() {


  1. Look into Liquibase its an excellent solution for doing migrations of the database, there is no reason why you can't use it from JUnit.

  2. 参考答案2
  3. You should just suppress the warning and go on. Once you switch to Spring 3.2, the transition will be trivial (remove all the Simple prefixes). There is no real reason to avoid SimpleJdbcTemplate at all costs in these tests, as its whole functionality is in JdbcTemplate under the same name.