Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

Is it worth designing a system's core to be independent of its frameworks, as hexagonal architecture suggests, when the system is expected to live 15 years? Use concrete migration history to argue.

For a complex system expected to live 15 years, yes, mostly. Over that time every framework goes through several major versions, and the javax to jakarta namespace move forced changes in every class that imported those types; a core free of framework types confines such migrations to adapters and configuration, and is also easier to test without containers. The cost is extra types and mapping code, which is too high for simple services, so the practical stance is to keep domain and use cases framework-free in long-lived, complex systems and use frameworks freely in the adapters.

Why this question is asked

Fifteen years is a long time in Java. A system started in 2011 would have begun on Java 6 and Spring 3, lived through Java 8 lambdas, the move to Spring Boot, the Java module system and the six-month release train, the javax to jakarta rename, and Spring Boot 3's Java 17 baseline. Interviewers ask senior candidates this question because it asks for judgement grounded in history rather than slogans: framework independence sounds good, but it has a price, and we should be able to say when it is worth paying. In this answer, we will recap what a framework-free core means, walk through real migrations of the last fifteen years, see how a core free of framework types changes their cost, weigh that against the price, and arrive at a practical stance.

1What a Framework-Free Core Means

Hexagonal architecture asks us to keep the domain model and use cases, the core, free of framework types. In Java terms, that means the core's classes import java.* and our own packages, but not org.springframework.*, jakarta.persistence.*, jakarta.servlet.* or a messaging library. Frameworks are used in adapters: controllers, JPA repositories, message listeners and clients, which implement interfaces the core defines.

It does not mean the system avoids frameworks. A framework-free core inside a Spring Boot application is normal: Spring creates the core objects and wires them to adapters. The point is that the business code does not depend on Spring's or JPA's types.

2Fifteen Years of Migrations, Concretely

The clearest example is the javax to jakarta rename. When Java EE moved to the Eclipse Foundation, the javax namespace could not be used for new versions, so Jakarta EE 9 renamed javax.persistence to jakarta.persistence, javax.servlet to jakarta.servlet, javax.validation to jakarta.validation, and so on. Spring Framework 6 and Spring Boot 3, released at the end of 2022, moved to the jakarta namespace. Every class that imported one of those types had to change, and libraries had to be upgraded in lockstep.

Around it were other migrations of the same kind. Moving from XML configuration to annotations and then to Spring Boot auto-configuration. Moving from JUnit 4 to JUnit 5, which changed every test import and runner. Replacing Hystrix, which went into maintenance, with Resilience4j. Hibernate 5 to 6 changed many APIs and some query behaviour. Spring Security's configuration style changed significantly when WebSecurityConfigurerAdapter was deprecated and then removed. And Spring Boot 3 required Java 17.

Framework migrations in a 15-year system
MigrationCode it touchesCore free of framework types?
javax -> jakarta (Boot 3)every import of persistence, servlet, validationonly adapters change
JUnit 4 -> JUnit 5every test classcore tests need only a new runner
Hystrix -> Resilience4jclient calls with fallbacksonly the client adapter
Hibernate 5 -> 6entities, queries, typesonly the persistence adapter
Spring Security config rewritesecurity configurationonly configuration
XML -> annotations -> Bootwiringcore unchanged, wiring rewritten
With a clean core, each row becomes an adapter or configuration change.

3How a Clean Core Changes the Cost

Imagine a system with 3,000 classes. In a typical layered codebase, the domain classes are JPA entities annotated with jakarta.persistence, services use Spring types, and validation annotations sit on domain objects. The jakarta rename then touches perhaps 1,500 files, many of them full of business logic, and each change carries the risk of a mistake in code that matters most.

If the domain and use cases are free of framework types, the same migration touches the adapters and configuration, perhaps 600 files, and those files contain technical code that is easier to change mechanically. The business rules do not change at all, and their tests, which do not start Spring, keep passing throughout the migration. That is the strongest argument: the code that is most expensive to get wrong is the code that a migration never touches.

Tools such as OpenRewrite reduced the cost of the jakarta move considerably for everyone, so the difference is smaller than it would have been in 2015. But tools change imports; they do not reason about behaviour changes such as Hibernate 6's different handling of some queries, and those need human review wherever framework types are used.

4Testing Without Containers

A second, everyday benefit is testing. A framework-free core can be tested with plain JUnit and in-memory implementations of its ports, so thousands of business-rule tests run in seconds without starting a Spring context, a database container or a broker. Over 15 years, that keeps the feedback loop fast even as the system grows, and it means the most important tests are the ones least affected by framework upgrades.

5The Price, and When It Is Too High

The independence is not free. The core needs its own types, so a customer appears as a request DTO, a domain object and a persistence entity, with mappings between them. We need port interfaces and configuration to wire them. For a service with real business rules, that extra code is a small fraction of the total and pays back in every migration and every test run.

For a simple CRUD service, the balance flips. There is little business logic, so the domain types mostly duplicate the entities, and the migration savings are small because there is little core code to protect. Many such services are also replaced before they reach 15 years. Paying the mapping cost on them is where the criticism of hexagonal architecture comes from, and it is fair.

6A Practical Stance

So my answer depends on two factors: how long the system will live and how much domain logic it holds. For a long-lived, complex system, I keep the domain and use cases free of framework types, allow frameworks freely in adapters and configuration, and accept the mapping cost. A small pragmatic exception, such as allowing @Transactional on use cases, is fine if it is a deliberate, written decision. For simple services, I accept framework types throughout and keep only the boundary rules, such as not exposing entities in APIs.

Notice that this stance is itself reversible. A service that starts simple and grows rules can extract a framework-free core module by module, as long as boundaries were kept clean from the start.

7Follow-up questions

Doesn't depending on Spring for 15 years make sense anyway, since Spring has lasted?

Spring has lasted, but its APIs have not stayed still: XML to Java configuration, Boot, the jakarta move, security configuration rewrites. Depending on Spring is fine; depending on Spring's types inside business rules is what makes each of those changes touch business code.

Are JPA annotations on domain classes acceptable?

It is a common compromise that saves a mapping layer. The cost is that the jakarta rename and Hibernate behaviour changes reach the domain, and JPA requirements like no-argument constructors shape the model. For a 15-year complex system I would keep them out of the core; for a medium-lived service I might accept them with eyes open.

What else besides frameworks changes over 15 years?

Databases, message brokers, cloud providers and external APIs. The same port and adapter boundary helps there too: replacing a payment provider or moving from a self-hosted broker to a managed one is an adapter change if the core only knows its own interfaces.

8Conclusion

In this answer, we argued from concrete history that a framework-free core is worth it for a complex system expected to live 15 years. Migrations such as javax to jakarta, JUnit 4 to 5, Hystrix to Resilience4j and Hibernate 5 to 6 touched every class that used those types, and a core without them confines that work to adapters and configuration while keeping fast container-free tests. The price is extra types and mapping, which is too high for simple services, so we keep domain and use cases framework-free where systems are long-lived and complex, and use frameworks freely in adapters.

What to say in the interviewAbout 90 seconds aloud

Open with

For a complex system that should live 15 years, I think it is worth it, and the history makes the case. In 15 years a Java system sees several framework generations.

Then, if they want more

The clearest example is the javax to jakarta rename: Spring Boot 3 moved to Jakarta EE namespaces, so every class importing javax.persistence, javax.servlet or javax.validation had to change. Around that we had JUnit 4 to 5, Hystrix going into maintenance and being replaced by Resilience4j, Hibernate 5 to 6, and the Spring Security configuration rewrite.

If the domain and use cases have no framework types, each of those migrations is confined to adapters and configuration. The business rules do not change, and their tests, which run without Spring or containers, keep passing during the migration, which is exactly the code I least want to touch.

The cost is real: separate DTOs, domain objects and entities, port interfaces, and mapping code. For a simple CRUD service that cost buys almost nothing, and such services are often replaced long before 15 years.

So my stance is to keep the domain and use cases free of framework types in long-lived, complex systems, use Spring and JPA freely in adapters, allow small written exceptions like @Transactional on use cases, and accept framework types throughout in simple services while still keeping entities out of APIs.

About this answer

Last updated
12 November 2026
Versions it names
Spring Boot 3, Hibernate 5, JUnit 4, Java 17
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Is it worth designing a system's core to be independent of its frameworks, as hexagonal...": https://scrivio-interview-library.netlify.app/java/application-architecture/b97a04d541/