The final paper came out at 14/24 (58%), short of the 22/24 target. Each miss is below with your pick, the answer and the reason. Before you open the reason, try to say the rule yourself. Then two drill blocks: new wording on the same facts to check you understand them, and the exact 22 again.
You did the final paper on 12 Oct, five days after the other blocks and without the rules screen open. Six of its ten misses were rules the final review listed as fixed or put on the one-screen list:
@PreDestroy visibility ("must be public" came back)@ImportAutoConfiguration for a slice testafterPropertiesSet() comes straight after BPP before-init@Autowired has only one attribute, and @Qualifier beats @PrimaryThis is forgetting, not misreading. The fix is the same rule re-tested after a gap, so do this page today, then do the Check block again in two or three days without looking at the cards.
On seven select-all questions you ticked only true options but left one out: uniform
interface, String init(), "hides dependencies", the private method, exclude = X.class,
@ImportAutoConfiguration, server.servlet.context-path. Give every option its own yes or
no, and don't submit until you've reached the last option.
Order: read the cards and try each "say it first" before opening it → Check: new wording → Retry: the 22. Aim for full marks on both. Then redo Check in 2–3 days.
| Drill block | Qs | Last | Best | Runs | Last done |
|---|---|---|---|---|---|
| Loading… | |||||
FP = final paper, WS = weak spots, SP = split it, RT = retry block.
@PreDestroy private void release() on a singleton. What happens when the context closes?
release() is called@PostConstruct methods?
static void init(), void init(String s) · Left out: String init()InitializingBean + @Bean(initMethod = "warm"). What runs straight after the BPP before-init hooks?
postProcessAfterInitialization · Answer: afterPropertiesSet()Valid: returns void, takes no parameters, isn't static. Visibility doesn't
matter, because Spring calls it by reflection, which can reach private methods. A return value is out, as the
JSR-250 spec requires void.
Order: constructor → injection → BPP before-init (where @PostConstruct runs) →
afterPropertiesSet() → initMethod → BPP after-init. The two hooks are the
bookends: all three init methods sit between them. So "after before-init" is always the next init
method, never the other bookend.
Rule: "void, no args, not static, any visibility. Init methods sit between the two BPP bookends: annotation → interface → custom."
null into one setter" · Answer: startup fails, reporting a cycle@Lazy on one constructor parameter@Lazy at an injection point can break a constructor cycle; the property exists only in Boot. Not: the property rescues a constructor cycle; switching a setter cycle to constructors fixes it.Spring builds A: it calls A's constructor, puts the half-built A in the singleton cache as an early reference, and then injects A's fields. A needs B, so Spring builds B. B needs A, and the cache already holds the early A. Done.
Constructor injection: A's constructor needs B before A exists, and B's constructor needs A. There's no object to cache, so it fails. Prototypes: they're never cached, so there's no early reference either. Fails.
Boot 2.6+ sets spring.main.allow-circular-references=false, so even the setter cycle
fails at startup with "The dependencies of some of the beans form a cycle". Spring never injects
null silently. @Lazy on one injection point injects a proxy instead of the real
bean, so neither constructor waits for the other. That fixes any cycle.
Rule: "Plain Spring: singleton setter/field start; constructor and prototype fail. Boot 2.6+: all fail. @Lazy fixes all. The property only brings the setter case back."
@Autowired(name = "x") · Answer: @Autowired @Qualifier("x"), @Autowired(required = false)stripe (@Primary) and paypal. Field: @Autowired @Qualifier("paypal") Gateway g;
stripe — @Primary always wins · Answer: paypal1. Find every bean of the type. 2. If there's a @Qualifier, keep only the matches. 3.
If more than one is left, pick the @Primary. 4. Otherwise match the field or parameter
name. 5. Otherwise throw NoUniqueBeanDefinitionException.
In FP24 the qualifier left only paypal, so @Primary never came into it.
@Primary is a tie-breaker. It doesn't override an explicit choice.
@Autowired has exactly one attribute, required. Naming a bean is
@Qualifier's job (or @Resource(name = …), which is a different annotation).
Rule: "Type → Qualifier → Primary → name → fail. @Autowired(required) and nothing else."
@WebMvcTest also needs MetricsClientAutoConfiguration. Best way to add it?
@SpringBootTest" · Answer: @ImportAutoConfiguration(MetricsClientAutoConfiguration.class)@SpringBootApplication, @EnableAutoConfiguration · Left out: @ImportAutoConfiguration@ContextConfiguration(classes = MyApp.class), where MyApp has @SpringBootApplication. Is auto-config loaded?
@ContextConfiguration switches auto-config off" · Answer: Yes, because MyApp's @SpringBootApplication brings it inFP1: "best way" means keep the slice. @SpringBootTest loads the whole application, which
gives up the reason for using @WebMvcTest (a small, fast context). @ImportAutoConfiguration
adds exactly one auto-config class to the slice. It's the same annotation the slices use internally.
WS6: @ContextConfiguration neither adds nor blocks anything. It loads the classes you
give it, and Spring processes their annotations. MyApp carries
@SpringBootApplication, which contains @EnableAutoConfiguration, so auto-config comes
in. Give it a plain @Configuration class and nothing comes in.
Rule: "Auto-config enters through @EnableAutoConfiguration, @SpringBootApplication, @ImportAutoConfiguration, and only those. Add one to a slice with @ImportAutoConfiguration."
exclude and excludeName?
exclude needs the class at compile time; excludeName doesn'tJacksonAutoConfiguration is on the classpath. Which remove it?
excludeName · Left out: exclude = JacksonAutoConfiguration.classexclude = DataSourceAutoConfiguration.class works when the class is on the classpath."
@Configuration?
@ConditionalOnMissingBean can see your beans and back offWS12 and SP4 show a new mix-up: you've started to think the .class form doesn't work at all. It
works fine, and it's the most common form. The only problem is that a .class literal must
compile, so it fails only when the class isn't on the classpath.
So they aren't aliases: exclude is Class<?>[] and excludeName is
String[]. They do the same job when the class is present, but only the string survives a missing
jar.
Timing: Boot imports auto-config with a deferred import selector, so it's processed after all
your configuration. That's the whole point: @ConditionalOnMissingBean can see that you defined a
DataSource and back off.
Rule: "Is the class missing? No → exclude, excludeName, property all work. Yes → strings only. Auto-config runs last so it can back off."
server.servlet.context-path is realserver.servlet.context-path is a real Spring Boot property."
server.tomcat.connection-timeout, server.port · Left out: server.servlet.context-pathIt sets the URL prefix for the whole app: server.servlet.context-path=/shop serves
/orders at http://host:8080/shop/orders. It sits under server.servlet.
because the context path is a servlet concept (servlet stacks only; WebFlux uses
spring.webflux.base-path). You got it right on weak spots Q2 and then doubted it twice. Trust it.
Rule: "Embedded-server settings live under server.: server.port, server.servlet.context-path, server.<tomcat|jetty>.…."
postProcessBeforeInstantiation · Answer: postProcessBeanFactorypostProcessBeanFactory(ConfigurableListableBeanFactory): the factory, which holds all the
definitions. It runs before any bean is created.
postProcessBeforeInstantiation(Class<?>, String) (on
InstantiationAwareBeanPostProcessor): one bean's class, just before its constructor runs.
postProcessBefore/AfterInitialization(Object, String): a built bean.
Last time "Before" tricked you, and this time it was "Instantiation". Don't go by those words. Look for BeanFactory in the name.
Rule: "Definitions = the one with BeanFactory in its name. Every BPP method gets a single bean (or its class)."
@Service. Which @Transactional calls silently run without a transaction?
this.save(), the final method · Left out: the private methodFinal: CGLIB can't override it, so the call goes straight to the original code. Private: it
isn't visible to a subclass, so it can't be overridden either. Self-call: this is the real
object, not the proxy. All three start up fine, and the advice just doesn't run.
Rule: "Silent = Final, Private, Self-call. Count to three before you submit."
Field injection: there's no constructor listing what the class needs, so its dependencies are
hidden. Spring sets private fields by reflection, which bypasses encapsulation. And you can't
just call new in a unit test, so it's harder to test. Its one advantage is that it's short
and easy to read.
REST ("Cool Students Can Use Lazy Code"): Client-server, Stateless, Cacheable, Uniform interface, Layered system, Code on demand (optional). Uniform interface = URIs + representations + self-descriptive messages + HATEOAS.
Rule: "Field injection: hidden, unencapsulated, hard to test. REST: C-S-C-U-L-C."
One or two questions for each miss, none worded the way you've seen. If you understand the rule and haven't just memorised the answer, these should all be right. Do this block again in 2–3 days.
The 22 questions you missed on the final review, reshuffled. Give every option a yes or no before you submit.
Full marks on both blocks means the 22 are understood. Redo Check: new wording in 2–3 days without reading the cards. If it's still full marks then, the rules have stuck, and the next step is a fresh practice exam. Paste this page if anything slips, and I'll target what's left.