springboot:using_h2_as_datasource_for_testing

This is an old revision of the document!


Using H2 As DataSource For Testing

  1. In build.gradle, add runtimeOnly 'com.h2database:h2 in dependencies section
  2. Open application.properties
  3. Add lines
    spring.datasource.url=jdbc:h2:mem:testdb
    spring.datasource.driverClassName=org.h2.Driver
    spring.datasource.username=sa
    spring.datasource.password=
    spring.h2.console.enabled=true

    Note that we set console.enable to true so that we can access H2 by web browser

  4. To access the H2 database, go to http://localhost:8080/h2-console/ for default setting
  • springboot/using_h2_as_datasource_for_testing.1590049782.txt.gz
  • Last modified: 2020/05/21 16:29
  • by chongtin