我正在尝试在应用程序启动时创建MySQL数据库。 我已经尝试了以下配置,但无法实现,请告诉我是否有人对此有想法,
spring.jpa.hibernate.ddl-auto=none
spring.datasource.initialization-mode=always
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
我正在尝试在应用程序启动时创建MySQL数据库。 我已经尝试了以下配置,但无法实现,请告诉我是否有人对此有想法,
spring.jpa.hibernate.ddl-auto=none
spring.datasource.initialization-mode=always
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
如果您想要创建数据库,如果不存在的话,您可以在数据库配置文件中使用以下内容。
jdbc:mysql://localhost:3306/dbname?createDatabaseIfNotExist=true
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/dbname
spring.datasource.username=username
spring.datasource.password=password
我已添加了以下选项:
"createDatabaseIfNotExist=true"
spring.datasource.url=jdbc:mysql://localhost:3306/"DB_NAME"?createDatabaseIfNotExist=true