Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save maxisandoval37/db853ee6b4c03e9b16066435ead0b044 to your computer and use it in GitHub Desktop.
Save maxisandoval37/db853ee6b4c03e9b16066435ead0b044 to your computer and use it in GitHub Desktop.
DB en memoria H2 con Spring Boot (Datos precargados y Consola)

DB en memoria H2 con Spring Boot

1) Configurar application.properties

#arrancar con datos SQL precargados -> agregar data.sql en /resources

spring.sql.init.mode=always
spring.jpa.defer-datasource-initialization=true

#configurar consola h2

spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=password
spring.h2.console.enabled=true

2) Crear archivo:

test.mv.db

• Windows

C:/Users/User

• Linux

/home/user/

3) Entrar a la consola

http://localhost:8080/contexto/h2-console/

h2

IMPORTANTE: El JDBC URL debe ser el mismo que el del properties, o si no, no carga las tablas!


Información Adicional

Para cualquier información adicional o consultas: [email protected]

Muchas gracias!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment