There is a web application using Spring Boot and JpaRepository interface to perform database queries. I want the application to be able to create tables in the database on its own at startup. How can this be done? Maybe I need to use Hibernate or something else for this? without xml
Asked
Active
Viewed 121 times
3 Answers
0
You need to add the JPA configurations to your application.properties file. Example of MySQL is below:
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=test
spring.datasource.password=
you can see some explanation here. Also, read about spring boot and JPA here.

Prog_G
- 1,539
- 1
- 8
- 22
0
Incase you want to use MySQL use the previous answer and if needed to use postgres then use the code given below.
spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://localhost:5432/schema_name
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQL95Dialect

Muthukumaran G
- 97
- 3