how to create mysql database and tables on the fly by spring boot web app

how to create mysql database and tables on the fly by spring boot web app

I can create a new database without any SSL warnings by this:-

spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto=create
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost/aaa?createDatabaseIfNotExist=true&useSSL=true
spring.datasource.username=root
pring.datasource.password=devv
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect

Spring Boot loads SQL scripts from the root of the classpath. You have to specify the data source properties in your application.yml or application.properties file.
You must specify your database in data source properties like this:

spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto=create
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=test
spring.datasource.password=

where test is your database.

how to create mysql database and tables on the fly by spring boot web app

Leave a Reply

Your email address will not be published. Required fields are marked *