简体   繁体   中英

creating a DB schema with application.yml

so I'm trying to create my schema with the application.yml, and it's just not working

spring:
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true

  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    username: root
    password: 1234
    url: jdbc:mysql://localhost:3306/schema
      ?useUnicode=true
      &createDatabaseIfNotExist=true
      &useJDBCCompliantTimezoneShift=true
      &useLegacyDatetimeCode=false
      &serverTimezone=UTC

server:
  port: 7070

application.yml is not responsible for schema or table creation. You only set up your datasource connection here.

For schema (tables) creation, if you are using spring boot, you need to have schema.sql somewhere on classpath (for example in src/resources folder) and data.sql for import statements and such.

Alternatively you could let Spring JPA do the work which it does automatically for your annotated classes with annotations @Entity.

More here https://www.baeldung.com/the-persistence-layer-with-spring-data-jpa

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM