I'm currently trying to set up my application with spring-boot to generate tables automatically but I still do not know how, can anyone help?
I'm currently trying to set up my application with spring-boot to generate tables automatically but I still do not know how, can anyone help?
You should create the application.properties
file and set up your database on it. Example:
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.url=jdbc\:mysql\://localhost/meu-banco
spring.jpa.hibernate.ddl-auto=update
When the spring.jpa.hibernate.ddl-auto
parameter is set to update
, when launching the application, Hibernate will check if the tables have already been created, if they have not yet been created, will create them automatically.
Another detail is that to create tables, their entities should be annotated with @Entity