Property spring.datasource.schema with value 'class path resource [schema-mysql.sql]' is invalid: The specified resource does not exist

Its old thread but someone else can get benefit of it, here full package class path and initialize schema always has to define..

need to define these properties:

spring.datasource.schema=classpath:/org/springframework/batch/core/schema-mysql.sql
spring.batch.initialize-schema=always

or in yml file:

spring:
  datasource:
    schema:
      - classpath:/org/springframework/batch/core/schema-mysql.sql
  jpa:
    hibernate:
      ddl-auto: create
  batch:
    initialize-schema: always

or if schema-mysql.sql is copied in resource folder then use spring.datasource.schema=classpath:schema-mysql.sql


The DDL scripts are located in the org.springframework.batch.core package, so you need to specify the datasource schema as follows in your properties files:

spring.datasource.schema=org/springframework/batch/core/schema-mysql.sql