[{"data":1,"prerenderedAt":15},["ShallowReactive",2],{"$f2p9rrdl4mmyw9":3},{"slug":4,"title":5,"date":6,"excerpt":7,"tags":8,"source":11,"aiAssisted":12,"readingTime":13,"html":14,"disabled":12},"migrating-spring-boot-2-to-3-2023Oct28","Migrating from Spring Boot 2 to Spring Boot 3","2023-10-28","Lessons from migrating a Spring Boot 2 microservice to Spring Boot 3 and thinking carefully about API evolution",[9,10],"Spring Boot","Microservices","LinkedIn",false,"2 min read","\u003Cp>Recently, I migrated a Spring Boot 2 microservice to Spring Boot 3. The project used Java 17, Spring Data JPA, Spring Batch 4, Google Cloud services such as Pub\u002FSub, and Cloud SQL PostgreSQL.\u003C\u002Fp>\n\u003Cp>This meant automatically migrating from Spring Framework 5 to 6, Hibernate 5 to Hibernate 6.2, Spring Batch 4 to 5, and more.\u003C\u002Fp>\n\u003Cp>The migration was relatively quick, following the \u003Ca href=\"https:\u002F\u002Flnkd.in\u002Fgsey99gC\">official migration guide\u003C\u002Fa>.\u003C\u002Fp>\n\u003Cp>There was one complication I ran into. Spring Batch 5 had many deprecation and other implementation changes.\u003C\u002Fp>\n\u003Cp>One of them was, and I quote from the documentation:\u003C\u002Fp>\n\u003Cblockquote>\n\u003Cp>Historically, Spring Batch provided a map-based job repository and job explorer implementations to work with an in-memory job repository. These implementations were deprecated in version 4 and completely removed in version 5. The recommended replacement is to use the JDBC-based implementations with an embedded database, such as H2, HSQL, and others.\u003C\u002Fp>\n\u003C\u002Fblockquote>\n\u003Cp>I had to dig deeper into the documentation to accommodate this change.\u003C\u002Fp>\n\u003Cp>You may ask, what is your point?\u003C\u002Fp>\n\u003Cp>Software engineers have to make conscious decisions when making changes to published public APIs, tools, and frameworks. Evolution is a constant. However, it has to be done carefully to minimize the effort required for migration. Also, the change must add value to its users, such as making it simpler to use. New features can be added, but they should not negatively impact current functionality running in production.\u003C\u002Fp>\n\u003Cp>In a microservices architecture, constantly changing business requirements require software engineers to update the REST API, internal service classes, and domain layer implementation.\u003C\u002Fp>\n\u003Cp>At times, only the internal implementation requires change. In this instance, the calling microservice does not need to change. But often, the request and response model classes require updates. In this instance, the developer can create a new API to accommodate this change or change the existing API. In both scenarios, the users of the other microservice need to be informed of the change so they can use it for their needs.\u003C\u002Fp>\n\u003Cp>To summarize, when building REST APIs, frameworks, and tools for public consumption by other services, they must be thoroughly discussed, designed, code-reviewed, well-documented, and communicated. In smaller projects, you can get away with just communication, but in projects with larger external impact, one should do all.\u003C\u002Fp>\n\u003Cp>Thanks for reading. Feel free to chime in the comments section.\u003C\u002Fp>\n\u003Cp>\u003Ca href=\"https:\u002F\u002Fwww.linkedin.com\u002Fposts\u002Fkamlesh1808_migrating-from-spring-boot-2-to-spring-boot-activity-7124080936933105664-ma_r\">Originally published on LinkedIn\u003C\u002Fa>.\u003C\u002Fp>\n",1792023078731]