数据库不是在spring.jpa.hibernate.ddl-auto = create之后创建的

时间:2016-05-24 09:13:18

标签: hibernate

数据库不是在application.properties中的spring.jpa.hibernate.ddl-auto = create之后创建的。

这是我的application.properties代码

# suppress inspection "UnusedProperty" for whole file

# Spring
spring.profiles.active=dev

# Server
server.port=8080
server.sessionTimeout=30

# JPA
spring.jpa.hibernate.ddl-auto=create
#spring.jpa.hibernate.ddl-auto=update -


# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy

# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
#spring.jpa.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
#spring.jpa.database=POSTGRESQL
spring.jpa.database=MYSQL
spring.jpa.show-sql=true

# Tomcat
tomcat.accessLogEnabled=false
tomcat.protocolHeader=x-forwarded-proto
tomcat.remoteIpHeader=x-forwarded-for
tomcat.backgroundProcessorDelay=30


# Connection url for the database "taskmanager"
#spring.datasource.url = jdbc:postgresql://localhost:5432/medooldoctor
spring.datasource.url= jdbc:mysql://localhost:3306/medooldoctor
#spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.driverClassName=com.mysql.jdbc.Driver

# Username and password
spring.datasource.username = root
#postgres
spring.datasource.password = root
#postgres

# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1

# Pretty-print JSON responses
spring.jackson.serialization.indent_output=true

在此之后,当我运行命令" show databases;"在终端中,没有创建数据库.....我该怎么做?

1 个答案:

答案 0 :(得分:2)

Hibernate不会创建数据库:spring.jpa.hibernate.ddl-auto=create意味着每个部署hibernate必须删除所有表(如果存在)并重新创建它们。它用于开发阶段,所以在你的情况下你指定你的数据库名是< strong> medooldoctor spring.datasource.url= jdbc:mysql://localhost:3306/medooldoctor .. hibernate将尝试在此数据库中生成您的架构,但它不会创建它。所以您必须访问phpmyadmin模块并使用名称medooldoctor手动创建数据库< / p>