|
| 1 | +# Migration guide |
| 2 | + |
| 3 | +## 2.x (Spring Boot 3.5) → 3.x (Spring Boot 4.0) |
| 4 | + |
| 5 | +Version `3.x` targets **Spring Boot 4.0** and makes **Jackson 3** (`tools.jackson.*`) the default |
| 6 | +JSON binding, matching Spring Boot 4's own default. To stay on Spring Boot 3.5, remain on the |
| 7 | +[`2.x` line](./README.md#compatibility) (branch `springboot-3.5.x`). |
| 8 | + |
| 9 | +### Prerequisites |
| 10 | + |
| 11 | +- Spring Boot **4.0.x** |
| 12 | +- Kotlin **2.2.21+** |
| 13 | +- JDK **17+** (unchanged) |
| 14 | + |
| 15 | +### 1. Bump the dependency |
| 16 | + |
| 17 | +```kotlin |
| 18 | +dependencies { |
| 19 | + implementation("com.caplin.integration.datasourcex:spring-boot-starter-datasource:3.+") |
| 20 | + // or, for the reactive / util modules: |
| 21 | + implementation("com.caplin.integration.datasourcex:datasourcex-kotlin:3.+") |
| 22 | +} |
| 23 | +``` |
| 24 | + |
| 25 | +### 2. Jackson 3 is now the default |
| 26 | + |
| 27 | +Spring Boot 4 auto-configures a Jackson 3 `tools.jackson.databind.ObjectMapper`, and the starter |
| 28 | +wires a Jackson-3-backed `JsonHandler` onto the DataSource by default. For most applications no |
| 29 | +change is required — plain POJOs serialize as before. |
| 30 | + |
| 31 | +If you registered **custom Jackson 2 modules, serializers, or `ObjectMapper` customizers**, port them |
| 32 | +to Jackson 3. See the |
| 33 | +[Jackson 3 release notes](https://github.com/FasterXML/jackson/wiki/Jackson-Release-3.0); the main |
| 34 | +changes are: |
| 35 | + |
| 36 | +- group/package `com.fasterxml.jackson.*` → `tools.jackson.*` (annotations stay on |
| 37 | + `com.fasterxml.jackson`), |
| 38 | +- `JsonSerializer` / `JsonDeserializer` → `ValueSerializer` / `ValueDeserializer`, |
| 39 | + `SerializerProvider` → `SerializationContext`, `JsonMappingException` → `DatabindException`, |
| 40 | +- the `ObjectMapper` is immutable — build it via `JsonMapper.builder()…build()`. |
| 41 | + |
| 42 | +### 3. Keeping Jackson 2 (optional) |
| 43 | + |
| 44 | +To keep using Jackson 2 for DataSource JSON, add Spring Boot's (deprecated) Jackson 2 module and |
| 45 | +define your own `JsonHandler` bean. The starter's handler is `@ConditionalOnMissingBean`, so yours |
| 46 | +takes precedence: |
| 47 | + |
| 48 | +```kotlin |
| 49 | +// build.gradle.kts |
| 50 | +implementation("org.springframework.boot:spring-boot-jackson2") |
| 51 | +``` |
| 52 | + |
| 53 | +```kotlin |
| 54 | +import com.caplin.datasource.messaging.json.JsonHandler |
| 55 | +import com.caplin.integration.datasourcex.util.SimpleDataSourceFactory |
| 56 | +import com.fasterxml.jackson.databind.ObjectMapper |
| 57 | +import org.springframework.context.annotation.Bean |
| 58 | + |
| 59 | +@Bean |
| 60 | +fun dataSourceJsonHandler(objectMapper: ObjectMapper): JsonHandler<*> = |
| 61 | + SimpleDataSourceFactory.createJackson2JsonHandler(objectMapper) |
| 62 | +``` |
| 63 | + |
| 64 | +Outside Spring, `SimpleDataSourceFactory.createDataSource(...)` now defaults to the Jackson 3 |
| 65 | +handler; pass `SimpleDataSourceFactory.defaultJackson2JsonHandler` (or your own) explicitly to keep |
| 66 | +Jackson 2. On the `3.x` line the Jackson 2 artifacts are `compileOnly` in `datasourcex-util`, so add |
| 67 | +them to your own classpath if you use the Jackson 2 helpers directly. |
| 68 | + |
| 69 | +### 4. Versioning note |
| 70 | + |
| 71 | +The published `.api` surface is unchanged between `2.x` and `3.x`; the breaking change is the Spring |
| 72 | +Boot 4 / Jackson 3 runtime baseline, which is why this is a major version bump. |
0 commit comments