gpt4 book ai didi

java - 自动创建数据库 springboot 和 mysql

转载 作者:行者123 更新时间:2023-12-02 17:02:13 24 4
gpt4 key购买 nike

我正在尝试在应用程序启动时创建 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

关于java - 自动创建数据库 springboot 和 mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53630079/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com