Kayıtlar

Persistence etiketine sahip yayınlar gösteriliyor

Spring Boot with H2

In this tutorial, we will examine the usage of the in-memory database h2 in a Spring Boot application. H2 is an in-memory database, we can use it for simple case-studies and quick show cases. Maven Dependencies This can be easily generated with Spring Starter. The dependency for Spring Data and JPA: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> The dependency for H2: <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency> H2 Configuration Now, we can configure the database settings in application.properties file: spring.datasource.url=jdbc:h2:mem:testdb spring.datasource.driverClassName=org.h2.Driver spring.jpa.database-platform=org.hibernate.dialect.H2Dialect spring.datasource.username=sa spring.datasource.password=password spring.h2.console.enabled...