Scrivio Interview library
LeadershipAdvanced6 min read · updated 12 November 2026

Would you set a standard that all configuration classes in your organisation use proxyBeanMethods = false? What are the arguments?

I would make proxyBeanMethods = false the default for new configuration classes and internal starters, but not impose it on existing code in one sweep. The arguments for it are that it removes CGLIB subclassing, which helps startup and AOT or native image builds, and that it forces dependencies to be explicit method parameters, which is clearer. The argument against a blanket rule is that existing classes that call @Bean methods directly change behaviour silently, so they must be reviewed, ideally with a static check, and migrated carefully.

Background to this question

Organisation-wide coding standards have a multiplier effect: a good rule improves hundreds of services, and a careless one breaks them at the same scale. proxyBeanMethods = false is a good example because the change is a single attribute, the benefit is real but modest, and the failure mode is silent. A leadership question like this wants us to weigh both sides, separate new code from existing code, and plan the rollout. In this answer, we will recap what the attribute does, set out the arguments for and against, look at how to find risky code automatically, and then describe the standard and rollout I would choose.

1A Quick Recap of the Attribute

A class annotated with @Configuration is, by default, subclassed at startup with CGLIB, a byte code generation library inside Spring. The subclass intercepts calls between @Bean methods, so calling dataSource() from another @Bean method returns the container's singleton. That is full mode.

With @Configuration(proxyBeanMethods = false), Spring skips the subclass. This is lite mode. The @Bean methods still define beans, but if one method calls another, it is a plain Java call and creates a new object. Code written for lite mode takes dependencies as @Bean method parameters instead, which works correctly in both modes.

2The Arguments For the Standard

The first argument is performance and compatibility. Each full-mode configuration class costs a generated subclass, created and loaded at startup. For a single class the cost is tiny, but a large service may have dozens of its own configuration classes on top of Boot's, and Spring AOT and GraalVM native images have less to handle without runtime-generated subclasses. Spring Boot itself writes every auto-configuration in lite mode for these reasons.

The second argument is clarity, and I think it is the stronger one. In lite mode, the only correct way to use another bean is a method parameter, so every dependency of every @Bean method is visible in its signature. Reviewers can see what a bean needs, the code reads like constructor injection, and nobody depends on a hidden interception that most engineers do not know exists.

Arguments for and against a blanket rule
ArgumentWeightApplies to
No CGLIB subclass: faster startupsmall per class, adds upall code
Simpler AOT and native image buildsreal for startup-sensitive servicesall code
Dependencies explicit as parametershigh, improves readabilityall code
Direct @Bean calls change behaviour silentlyhigh risk, no error at startupexisting code
Migration effort and review timemoderateexisting code

3The Argument Against: Silent Behaviour Changes

The risk lies entirely in existing code. Any configuration class that calls one of its own @Bean methods directly relies on full mode. Adding proxyBeanMethods = false to it compiles, starts and passes most tests, yet now creates extra objects outside the container. For a stateless bean that only wastes a little memory. For a DataSource it creates a second connection pool that is never closed, for a cache it creates a second cache with different contents, and for a transaction manager on a different DataSource it breaks transactions.

Java
@Configuration(proxyBeanMethods = false) // added by a well-meaning sweep
class CacheConfig {
@Bean CacheManager cacheManager() { return new CaffeineCacheManager("prices"); }
@Bean PriceService priceService() { return new PriceService(cacheManager()); } // a second, separate cache
}
// Evictions through the cacheManager bean no longer affect PriceService

Because nothing fails at startup, a blanket change across hundreds of services would introduce bugs that surface weeks later in production. That is the reason not to apply the rule to existing code without review.

4Making the Risk Visible With a Static Check

The risky pattern is mechanical, so it can be detected mechanically. A check needs to find, inside a class with @Bean methods, any call to another @Bean method of the same class that is not through a parameter. An ArchUnit rule, a small custom check in the build, or a code search with a careful pattern can do it. With the check in CI, new code cannot introduce the pattern, and existing classes can be classified as safe to switch or needing changes.

Java
// Sketch of an ArchUnit rule: no @Bean method may call another @Bean method directly
ArchRule noInterBeanCalls = methods().that().areAnnotatedWith(Bean.class)
.should(new ArchCondition<JavaMethod>("not call other @Bean methods directly") {
@Override public void check(JavaMethod m, ConditionEvents events) {
m.getMethodCallsFromSelf().stream()
.filter(call -> call.getTarget().isAnnotatedWith(Bean.class))
.forEach(call -> events.add(SimpleConditionEvent.violated(m,
m.getFullName() + " calls " + call.getTarget().getName())));
}
});
// Violation: CacheConfig.priceService() calls cacheManager

The exact ArchUnit API may differ slightly between versions, so treat this as a sketch and check the version in use; the idea is what matters.

5The Standard and Rollout I Would Choose

For new code, the standard is simple: configuration classes use proxyBeanMethods = false and receive dependencies as method parameters, and the static check enforces the no-direct-calls part. Internal starters and auto-configurations follow the same rule, matching Spring Boot. The service template is updated so new services start this way.

For existing code, the rule is migrate with care, not migrate now. A class switches only when it passes the static check or after its direct calls are rewritten as parameters, in a reviewed change with the service's tests passing. Teams do this when they touch the configuration anyway, or when a service needs faster startup or AOT. A class that stays in full mode is not a defect; it is simply not yet migrated. This gets most of the benefit with almost none of the risk.

Step throughRolling out the standard
  1. New configuration class or starter?
    YesproxyBeanMethods = false, parameters onlyNoGo on
  2. Existing class passes the no-direct-calls check?
    YesSwitch it in a reviewed changeNoGo on
  3. Rewrite direct calls as parametersthen switch, with tests
  4. CI check prevents the pattern from returningapplies to all code

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

6Follow-up questions

Is the startup gain worth a standard at all?

On its own, the gain is modest, often milliseconds per class. The stronger reasons are explicit dependencies and fewer surprises for AOT and native images. If the standard only promised speed, I would not push it; it earns its place because it also makes configuration easier to read and review.

Would you ever keep full mode deliberately?

Only where a class relies on inter-bean calls and rewriting it brings no value, such as a stable legacy service that nobody changes. Even then, the static check documents the dependency on full mode, so a later sweep does not break it by accident.

How do you communicate the standard?

With a short page explaining the reason, one before-and-after example showing the duplicate-bean bug, the CI check that gives a clear message, and the updated service template. Engineers follow a rule much more willingly when they have seen the failure it prevents.

7Conclusion

In this answer, we weighed an organisation-wide rule for proxyBeanMethods = false. It removes CGLIB subclassing, which helps startup and AOT or native image builds, and it forces explicit dependencies through @Bean method parameters, which is clearer. The risk is that existing code calling @Bean methods directly silently changes behaviour, so it needs review or static checks. The standard we chose makes lite mode the default for new code and internal starters and migrates existing classes carefully, with a CI check guarding against direct inter-bean calls.

What to say in the interviewAbout 90 seconds aloud

Open with

I would make it the default for new code, not a blanket rule for existing code. The arguments for it are real. Without proxyBeanMethods, Spring skips generating a CGLIB subclass for every configuration class, which helps startup a little and makes AOT and native images simpler; that is why Spring Boot writes all its auto-configurations this way.

Then, if they want more

The bigger benefit for me is clarity: in lite mode the only correct way to use another bean is a method parameter, so every dependency is visible in the signature and nobody relies on a hidden interception. The argument against applying it everywhere at once is that existing classes that call their own @Bean methods directly change behaviour silently.

They still start and pass most tests, but now create extra objects outside the container: a second connection pool that never closes, a second cache, or a transaction manager on a different DataSource.

So my standard would be: new configuration classes and internal starters use proxyBeanMethods = false with parameter injection, enforced by a CI check, for example an ArchUnit rule that flags a @Bean method calling another @Bean method.

Existing classes switch only after they pass that check or after their direct calls are rewritten, in a reviewed change with tests, typically when the team touches that configuration anyway or needs AOT. Classes left in full mode are not defects, just not migrated yet.

About this answer

Last updated
12 November 2026
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 "Would you set a standard that all configuration classes in your organisation use...": https://scrivio-interview-library.netlify.app/spring-boot/ioc-container/f4d3c50512/