2525
2626import org .springframework .boot .autoconfigure .AutoConfigurations ;
2727import org .springframework .boot .autoconfigure .context .PropertyPlaceholderAutoConfiguration ;
28- import org .springframework .boot .jdbc .DataSourceBuilder ;
2928import org .springframework .boot .test .context .runner .ApplicationContextRunner ;
3029import org .springframework .cloud .task .listener .TaskLifecycleListener ;
3130import org .springframework .cloud .task .repository .TaskExecution ;
3433import org .springframework .context .annotation .Configuration ;
3534import org .springframework .jdbc .core .JdbcTemplate ;
3635import org .springframework .jdbc .datasource .DataSourceTransactionManager ;
36+ import org .springframework .jdbc .datasource .embedded .EmbeddedDatabaseBuilder ;
37+ import org .springframework .jdbc .datasource .embedded .EmbeddedDatabaseType ;
3738import org .springframework .test .jdbc .JdbcTestUtils ;
3839import org .springframework .test .util .ReflectionTestUtils ;
3940import org .springframework .transaction .PlatformTransactionManager ;
@@ -118,10 +119,7 @@ public TaskConfigurer taskConfigurer(DataSource dataSource) {
118119
119120 @ Bean
120121 public DataSource dataSource () {
121- DataSourceBuilder dsb = DataSourceBuilder .create ()
122- .url ("jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE" );
123- dsb .driverClassName ("org.h2.Driver" );
124- return dsb .build ();
122+ return new EmbeddedDatabaseBuilder ().setType (EmbeddedDatabaseType .H2 ).build ();
125123 }
126124
127125 }
@@ -143,10 +141,7 @@ public PlatformTransactionManager getTransactionManager() {
143141
144142 @ Bean
145143 public DataSource dataSource () {
146- DataSourceBuilder dsb = DataSourceBuilder .create ()
147- .url ("jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE" );
148- dsb .driverClassName ("org.h2.Driver" );
149- return dsb .build ();
144+ return new EmbeddedDatabaseBuilder ().setType (EmbeddedDatabaseType .H2 ).build ();
150145 }
151146
152147 @ Bean
@@ -173,10 +168,7 @@ public PlatformTransactionManager getTransactionManager() {
173168
174169 @ Bean
175170 public DataSource dataSource () {
176- DataSourceBuilder dsb = DataSourceBuilder .create ()
177- .url ("jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE" );
178- dsb .driverClassName ("org.h2.Driver" );
179- return dsb .build ();
171+ return new EmbeddedDatabaseBuilder ().setType (EmbeddedDatabaseType .H2 ).build ();
180172 }
181173
182174 @ Bean
@@ -186,10 +178,7 @@ public DataSourceTransactionManager transactionManager(DataSource dataSource) {
186178
187179 @ Bean
188180 public DataSource dataSource2 () {
189- DataSourceBuilder dsb = DataSourceBuilder .create ()
190- .url ("jdbc:h2:mem:testdb2;DB_CLOSE_ON_EXIT=FALSE" );
191- dsb .driverClassName ("org.h2.Driver" );
192- return dsb .build ();
181+ return new EmbeddedDatabaseBuilder ().setType (EmbeddedDatabaseType .H2 ).build ();
193182 }
194183
195184 @ Bean
0 commit comments