import javax.sql.DataSource;

@Autowired
private DataSource dataSource;
ClassPathResource classPathResource = new ClassPathResource("xxx.sql");
try (Connection connection = dataSource.getConnection()) {
	ScriptUtils.executeSqlScript(connection, classPathResource);
} catch (SQLException e) {
	return;
}

xxx.sql放在resources目录下
ScriptUtils使用org.springframework.jdbc.datasource.init