1

My spring-boot configuration is:

spring:
  profiles: database
  datasource:
    platform: mysql
    continueOnError: false
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/test
    username: root
    data: data-mysql.sql
    schema: schema-mysql.sql
  batch:
    initializer:
      enabled: true
    initialize-schema: always
    job:
      enabled: true
  jpa:
    database-platform: org.hibernate.dialect.MySQLDialect
    show-sql: true
    hibernate:
      ddl-auto: create-drop

My expectation is:

  • spring-batch schema will be created each time from very beginning;
  • customer table specified in the schema-mysql.sql will be created every start time;
  • customer data will specified in the data-mysql.sql be populated every start time;

But the actual result is:

  • spring-batch schema is created only first time;
  • customer table never populated with data;
  • customer table never created;

Question:

How should I change my configuration to get next result:

  • I'm ok if spring-batch schema is created only once or every start time (but it should be created for absence case);
  • customer table should be created only once or every time;
  • customer table should be populated with data if no data there.

Details:

  • spring-boot 2.2.0.M3;
  • Gradle 5.4.1;
  • mariadb.
2
  • First remove hibernate: ddl-auto: create-drop because you are already using schema.sql Commented Jun 14, 2019 at 8:51
  • @SimonMartinelli, thanks. I know, that is not required for my purpose, but I tried a lot of different combinations and that doesn't work any way. (I mean ddl-auto = never or absent also doesn't work) Commented Jun 14, 2019 at 9:13

1 Answer 1

1

I can't see that you configured to execute the schema and data file.

You have to add:

spring:
    datasource:
        initialization-mode: always
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.