官网
http://www.h2database.com/html/features.html
查找 Execute SQL on connection
在配置类中 设置DataSource
@Bean
public DataSource dataSource() {
// return new EmbeddedDatabaseBuilder()
// .setType(EmbeddedDatabaseType.H2)
// .addScripts("classpath:spittr/db/jdbc/schema.sql", "classpath:spittr/db/jdbc/test-data.sql")
// .build();
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.h2.Driver");
dataSource.setUsername("embedded");
dataSource.setPassword("embedded");
dataSource.setUrl("jdbc:h2:~/example/testDB;INIT=create schema if not exists Queue\\; " +
"runscript from '~/example/schema.sql'\\;" +
"runscript from '~/example/test-data.sql'\\;");
return dataSource;
}