Scrivio Interview library
LeadershipPrincipal7 min read · updated 12 November 2026

Over twenty years Java frameworks moved from XML configuration to annotations and now partly toward explicit Java configuration and build-time processing. What does that history teach about where configuration should live, and what would you standardise for the next decade?

XML kept configuration apart from code but was verbose and unchecked by the compiler; annotations moved configuration next to the code and made it type-checked, but hid behaviour behind processors that run out of sight; explicit Java configuration and functional bean registration are easiest to trace and fit ahead-of-time processing and native images. The lesson is that configuration should live where it is checked by tools and easy to follow: annotations for well-known framework concerns, explicit code for business wiring, and mechanisms that can be resolved at build time, because startup cost and native images matter more each year.

Why this question is asked

Senior engineers are often asked to set standards that will outlast the current framework version. The history of Java configuration is the best evidence we have for what lasts: three times in twenty years the ecosystem changed where configuration lives, and each change solved the previous era's pain while creating a new one. Interviewers ask this to see whether we can draw principles from that history rather than follow fashion. In this answer, we will walk through the three eras and what each taught, then turn those lessons into standards for the next decade, with the trade-offs each one costs.

1The XML Era: Separate, Verbose, Unchecked

In the mid-2000s, Spring applications, EJB deployment descriptors and Hibernate mappings were configured in XML. The idea was sound: wiring is a separate concern from logic, so keep it in separate files that operations can change without recompiling.

In practice, the files grew to thousands of lines, every class name and property was a string the compiler never checked, and a renamed class broke the application only at startup. Reading the code told you nothing about how it was wired; you had to cross-reference files. The lesson was that separation is not free: configuration the compiler cannot check, and that sits far from the code it affects, is costly to maintain.

XML
<!-- applicationContext.xml, circa 2006 -->
<bean id="orderService" class="com.acme.OrderService">
<property name="repository" ref="orderRepository"/> <!-- a typo here fails only at startup -->
</bean>
<tx:annotation-driven/>

2The Annotation Era: Close to Code, Hidden Behaviour

Java 5 annotations, then Spring 2.5 and later and JPA, moved configuration onto the classes themselves. @Component, @Autowired, @Transactional and @Entity are next to the code they affect, the compiler checks their names and types, and refactoring tools rename them safely. Spring Boot's auto-configuration took this further: add a dependency and the right beans appear.

The cost appeared slowly. Behaviour now came from processors that run out of sight: classpath scanning, proxies, conditions evaluated at startup. Startup time grew with the number of classes scanned and reflected over, and debugging meant asking why a bean exists or why a proxy did not apply, questions the code itself cannot answer. The lesson was that putting configuration near code is good, but hiding behaviour behind it has a price that grows with the size of the system.

3The Current Shift: Explicit Code and Build-Time Processing

Two pressures drive the current shift. Containers and serverless platforms reward fast startup and low memory, and GraalVM native images need to know at build time which classes, proxies and reflection the application uses, because a closed-world image cannot discover them at run time. Frameworks responded by moving work to the build. Spring Framework 6 and Spring Boot 3 added ahead-of-time processing that evaluates configuration during the build and generates plain Java code for bean definitions. Quarkus and Micronaut were designed around build-time processing from the start, and Dagger long ago showed dependency injection generated entirely at compile time.

Explicit configuration came back too, but in Java rather than XML: @Bean methods, and functional or programmatic bean registration, such as the BeanRegistrar API that Spring Framework 7 introduces for registering beans in code (check your version for details). These are type-checked, navigable with a click, and easy for AOT processing to analyse.

Java
// Explicit, type-checked, traceable wiring
@Configuration
class OrderConfig {
@Bean
OrderService orderService(OrderRepository repository, Clock clock) {
return new OrderService(repository, clock); // the constructor call is the whole story
}
}
Three eras of Java configuration
EraWhere configuration livedGainCost
XML (about 2003-2010)Separate filesSeparation, change without recompilingVerbose, unchecked strings, far from code
Annotations (about 2008-2020)On the classesNext to code, type-checkedHidden processors, scanning cost at startup
Explicit code + build time (now)Java config, generated codeTraceable, AOT and native friendlyMore code to write, build-time tooling
Dates are approximate; the eras overlap, and most systems today mix all three.

Notice what is gained: a reader sees exactly how OrderService is built, the compiler checks it, and an AOT step can process it without scanning or reflection.

4What the History Teaches

Read together, the eras point to three lasting principles. First, configuration should be checked by tools: XML failed largely because nothing checked it, and every later approach was type-checked. Second, behaviour should be traceable from the code a reader is looking at: annotations kept the first property but lost some of the second, and the current shift restores it. Third, the cost of resolving configuration should be paid as early as possible: at build time rather than at every startup, because a modern system starts thousands of times a day across instances, tests and deployments.

None of this says annotations were a mistake. Annotations for well-understood framework concerns, like @Transactional or @GetMapping, are a shared vocabulary every Java developer reads fluently, and build-time frameworks still use them as input. The problem was using them for everything, including business wiring that should have been visible.

5What I Would Standardise for the Next Decade

First, annotations for well-known framework concerns: the standard Spring, Jakarta and JPA annotations, plus a small, centrally owned set of our own composed annotations, each documented and tested. Second, explicit code for business wiring: constructor injection everywhere, @Bean methods or programmatic registration for anything non-obvious, and no custom run-time annotations that trigger business behaviour. Third, a preference for mechanisms that can be processed at build time: compile-time annotation processors such as MapStruct over run-time reflection, Spring AOT compatibility as a requirement for shared starters, and a native-image build in CI for services where startup matters, even if they ship on the JVM, because it keeps them honest about reflection.

Finally, standardise on measurement rather than fashion: track startup time and memory per service, so the next shift, whatever it is, is chosen on evidence. Each standard costs something: explicit code is longer, and build-time processing makes builds slower and tooling more complex. I accept those costs because they are paid once by the author and the build, while hidden behaviour and slow startup are paid by every reader and every instance.

Step throughWhere should a new piece of configuration live?
  1. Is it a well-known framework concern?
    YesUse the standard annotationNoContinue
  2. Is it business wiring?
    YesExplicit Java config or constructor codeNoContinue
  3. Does it vary per environment?
    YesExternalised properties, type-safe bindingNoExplicit Java config
  4. Check it resolves at build timeAOT and native image compatible

4 steps in order. Play them, or step through them one at a time.

6Follow-up questions

Does build-time processing make annotations obsolete?

No. Build-time frameworks still use annotations as their input; what changes is when they are read. Quarkus or Spring AOT read @Inject or @Bean during the build and generate code, so the annotation remains the readable declaration while the run-time cost of scanning and reflection goes away.

Where does externalised configuration such as application.yml fit?

It survives every era because it serves a different purpose: values that differ per environment, like URLs, pool sizes and feature flags. The lesson from XML applies to it too, so we bind it to type-safe classes with @ConfigurationProperties and validation, so mistakes fail at startup or in tests rather than in production.

How would you migrate a large annotation-heavy codebase toward this?

Gradually and by value. Start with AOT compatibility in shared starters, because that unblocks every service, then replace custom run-time annotations that hide business behaviour, and move non-obvious bean wiring into explicit configuration when those areas are touched anyway. A big-bang rewrite would cost far more than the benefit.

7Conclusion

In this answer, we followed Java configuration through three eras. XML separated configuration from code but was verbose and unchecked, annotations put configuration next to code with type checking but hid behaviour behind processors and added startup cost, and explicit Java configuration with build-time processing restores traceability and suits AOT and native images. The lessons are that configuration should be tool-checked, traceable and resolved as early as possible, so we standardise annotations for well-known framework concerns, explicit code for business wiring, and mechanisms that can be processed at build time.

What to say in the interviewAbout 90 seconds aloud

Open with

Each era solved the previous one's pain and created its own. XML kept configuration separate from code, which sounded right, but it was verbose, every class name was an unchecked string, and you could not understand the wiring by reading the code.

Then, if they want more

Annotations moved configuration next to the code and made it type-checked, which was a huge improvement, but behaviour started coming from processors you cannot see: scanning, proxies, conditions, and startup cost grew with the codebase.

Now, with containers and native images, frameworks are moving work to build time, like Spring AOT, Quarkus and Micronaut, and explicit Java configuration and programmatic bean registration are back because they are traceable and easy to process ahead of time.

The lessons I draw are that configuration should be checked by tools, traceable from the code you are reading, and resolved as early as possible, ideally in the build rather than at every startup.

So for the next decade I would standardise on three things: the well-known framework annotations for well-known concerns, like transactions, web mappings and persistence; explicit code for business wiring, meaning constructor injection, @Bean methods where it is not obvious, and no custom run-time annotations that trigger business logic; and a preference for build-time mechanisms, such as compile-time processors over reflection and AOT compatibility as a requirement for shared starters.

And I would measure startup and memory so the next change is based on evidence.

About this answer

Last updated
12 November 2026
Versions it names
Java 5, Spring Boot 3, Spring Framework 6, Spring Framework 7
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. 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 "Over twenty years Java frameworks moved from XML configuration to annotations and now...": https://scrivio-interview-library.netlify.app/java/annotations/80bae440a0/