openrewrite / openrewrite/rewrite-spring
2.4-2.5: SQL Script DataSource Initialization
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 403
- Forks
- 149
- Avg merge
- 2h 33m
- Merged PRs (30d)
- 10
Description
Spring Boot 2.5.6 Release Notes
The underlying method used to support schema.sql and data.sql scripts has been redesigned in Spring Boot 2.5. spring.datasource.* properties related to DataSource initialization have been deprecated in favor of new spring.sql.init.* properties. These properties can also be used to initialize an SQL database accessed via R2DBC.
Implement an Action to handle SQL Script DataSource Initialization
Condition
deprecated spring.datasource.* property found in any properties file.
Recipe
Replace the deprecated properties with their new values as defined in the table below.
Report
- Display the defined properties and their replacement in Spring Boot 2.5
- Show the resource path where the property was found
Relevance
The scan found properties in your application that were deprecated in Spring Boot 2.5.
These need to be replaced with their new values.
Please see the table below for more information about what needs to be changed.
Todo
- List all deprecated properties and their replacement and the files they are defined in.
Resources
Spring Boot 2.5.6 reference - A.7. Data Migration Properties
Spring Boot 2.4.12 reference - 11.A.5. Data Properties
| Spring Boot 2.4.12 | Spring Boot 2.5.6 | 2.5.6 | 2.4.12 | ||
|---|---|---|---|---|---|
spring.datasource.continue-on-error |
spring.sql.init.continue-on-error |
Whether initialization should continue when an error occurs. | |||
spring.datasource.data |
spring.sql.init.data-locations |
Locations of the data (DML) scripts to apply to the database. | |||
spring.datasource.sql-script-encoding |
spring.sql.init.encoding |
Encoding of the schema and data scripts. | |||
spring.datasource.initialization-mode |
spring.sql.init.mode |
Mode to apply when determining whether initialization should be performed. | |||
| *see below | spring.sql.init.username |
Username of the database to use when applying initialization scripts (if different). | |||
| *see below | spring.sql.init.password |
Password of the database to use when applying initialization scripts (if different). | |||
spring.datasource.platform |
spring.sql.init.platform |
||||
spring.datasource.schema |
spring.sql.init.schema-locations |
Schema (DDL) script resource references. | |||
spring.datasource.schema-password |
*see below | Password of the database to execute DDL scripts (if different). | |||
spring.datasource.schema-username |
*see below | Username of the database to execute DDL scripts (if different). | |||
spring.datasource.separator |
spring.sql.init.separator |
Statement separator in SQL initialization scripts. | |||
spring.datasource.data-password |
*see below | ||||
spring.datasource.data-username |
*see below | Username of the database to execute DML scripts (if different). |
- Different credentials for
spring.datasource.data-*andspring.datasource.schema-*are not supported anymore. Ifdata.sqlorschema.sqlexist orspring.datasource.schemaandspring.datasource.dataare set it is not possible to tell if separate credentials are used.
If this is the case, 'Separate Credentials' must be applied.
If they are not set/found, the property can be replaced with the nrespring.sql.init.*relacement
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Spring Boot 2.5.6 release notes and the linked 2.4.12 and 2.5.6 application-property references. Use the condition and migration table to identify deprecated spring.datasource.* properties, then define the replacements, resource-path reporting, and separate-credentials behavior described in the issue. Done means the action reports each finding and its replacement, or applies the specified migration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100