Does it store it in cache? I have an application and nowhere in the application.properties are db details mentioned. I am able to store data and query it via Postman.
Asked
Active
Viewed 1,153 times
1
-
2Then you're probably using Spring Boot with an in-memory database. https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-embedded-database-support – JB Nizet Aug 15 '19 at 19:17
-
Does this answer your question? [Spring boot Jpa: hibernate as default?](https://stackoverflow.com/questions/41902856/spring-boot-jpa-hibernate-as-default) – DV82XL Aug 02 '20 at 02:12
-
@DV82XL The fact it uses Hibernate does not answer **where** it stores the data. – Mark Rotteveel Aug 02 '20 at 08:10
1 Answers
3
Spring Boot uses auto-configuration to configure persistence based on what dependencies are present on the class path. For example, If you provide a dependency to spring-boot-starter-data-jpa
in pom.xml
with no other config, JPA/Hibernate
uses an in-memory H2
database by default. You can make this explicit by adding the following to application.properties
:
spring.datasource.url=jdbc:h2:mem:testdb
spring.data.jpa.repositories.bootstrap-mode=default
spring.datasource.driverClassName=org.h2.Driver
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
By default, the contents of the in-memory H2
database are stored in volatile memory, so will be lost when your application terminates. You can store data to a local file by adding this to application.properties
:
spring.datasource.url=jdbc:h2:file:/path/to/my/data
To view the contents of the H2
database in a console, add the following to application.properties
and go to http://localhost:8080/h2-console :
spring.h2.console.enabled=true

DV82XL
- 5,350
- 5
- 30
- 59