I am making my own ORM and I'm at the point where I need to push the SQL code I've generated from my entity classes to the database. I do not aim to copy how Spring does it but rather see what phase of the lifecycle it runs in and how exactly.
Thanks
The actual class that read schema.sql
and execute it is DataSourceInitializer#createSchema()
.
Here are the high level flow which somehow triggers it:
DataSource
class is found from the class-path, spring-boot auto-configuration will enable DataSourceAutoConfiguration
DataSourceAutoConfiguration
imports DataSourceInitializationConfiguration
DataSourceInitializationConfiguration
registers DataSourceInitializerPostProcessor
which will be executed and force initialising DataSourceInitializerInvoker
. DataSourceInitializerInvoker
's afterPropertiesSet
will then execute DataSourceInitializer#createSchema()
to read and execute schema.sql
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.