I have a springboot application where I am trying to add following to application.properties
file
spring.datasource.initialize=false
When I add this I see a warning as below:
I tried finding out what's the new property that replaces this deprecated property but in vain.
Can anybody help on this!
Having a reference to a migration guide would be great.
82.3 Initialize a DatabaseSpring Boot can automatically create the schema (DDL scripts) of your DataSource and initialize it (DML scripts). It loads SQL from the standard root classpath locations: schema. sql and data. sql , respectively. In addition, Spring Boot processes the schema-${platform}.
sql. init mode to always initialize the SQL database. It also enables the fail-fast feature by default for the script-based database initializer, i.e. the application cannot start if the scripts throw exceptions.
spring. jpa. hibernate. ddl-auto (enum) is a Hibernate feature that controls the behavior in a more fine-grained way.
In Spring Boot 2.5, 'spring.datasource.initialization-mode' has been depracated as well: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.5-Release-Notes#SQL-Script-DataSource-Initialization
you should use:
spring.sql.init.mode=always
or
spring.sql.init.mode=never
You can read more at:
https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto.data-initialization
As per the document
Spring Boot automatically creates the schema of an embedded DataSource. This behaviour can be customized by using the spring.datasource.initialization-mode property. For instance, if you want to always initialize the DataSource regardless of its type:
spring.datasource.initialization-mode=always
Look at this migration guide
As per Spring Boot Migration mentioned in Github
Basic DataSource initialization is now only enabled for embedded data sources and will switch off as soon as you’re using a production database. The new spring.datasource.initialization-mode (replacing spring.datasource.initialize) offers more control.
spring.datasource.initialization-mode=always
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With