Setting up in-memory H2 database without Spring Boot
问题 I am working in a spring 5 (Not Sprig Boot) project. I need to test my application with in-memory H2 database. I am using Spring with Java Config on maven build tool. Is there any way I can configure in-memory H2 DB? 回答1: Usually I use this in my @Config class: @Bean public DataSource h2TestDataSource(){ return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build(); } So I use Spring Embedded DB in my spring projects (I don't use spring boot) I hope it's useful. 回答2: You can