Exam Review #2 · 14 Aug 2026 · 20 to fix

Second attempt — what I got wrong (and how to nail it)

You scored 40 / 60 = 67%+1 mark on attempt #1. Pass is 76% (46/60), so you're now just +6 questions away. Read each fix, then drill the quiz at the end of every section (options reshuffle on each load).

67%
This attempt (40/60)
65%
Attempt #1 (39/60)
76%
Pass mark (46/60)
+6
Questions to pass
Trend: 39 → 40. Small gain, but the misses have shifted — this time it's Transactions and @WebMvcTest / test slices doing the damage, plus a run of SpEL and bean-configuration facts. Nail the four clusters below and you clear 76%.
Where you bled points this time Spring Core (7), Data Management / transactions (7), Testing (4), Spring Boot (2). Notice how many are transactions — that whole topic is worth revisiting end-to-end.

Jump to a section

① Spring Core — 7 misses ② Data Management / Transactions — 7 misses ③ Testing — 4 misses ④ Spring Boot & Actuator — 2 misses

① Spring Core 7 misses

Q2 · Maven exclusions

An <exclusion> removes that artifact from the classpath — with no substitute

Excluding spring-web from a dependency completely removes it from the classpath. Maven does not log-and-continue, does not auto-replace it, and does not pin a version. If the library actually needs it at runtime you get ClassNotFoundException / NoClassDefFoundError. Only that one transitive dep is removed (not all Spring deps). You can optionally add your own version back explicitly.

Memory hook: exclusion = delete, no replacement. Use mvn dependency:tree to check what breaks.
Q7 · @ComponentScan vs explicit @Bean

Best practice = combine them; never rely on scanning exclusively

True best practices: use @ComponentScan to cut boilerplate on large projects; define beans explicitly for control (ordering, init, third-party classes); combine both; and avoid scanning when several beans share a type/name (prevents NoUniqueBeanDefinitionException). The wrong option was "rely exclusively on @ComponentScan" — that surrenders control over tricky beans.

Memory hook: Scan for the many, explicit @Bean for the tricky. Combine — never "exclusively".
Q16 · Non-web ApplicationContext

Standalone contexts: ClassPathXml…, FileSystemXml…, AnnotationConfig…

The three real non-web implementations are ClassPathXmlApplicationContext (XML on classpath), FileSystemXmlApplicationContext (XML on filesystem) and AnnotationConfigApplicationContext (@Configuration classes — the modern default). XmlWebApplicationContext is web-only (needs a servlet container). FileSystemTxtApplicationContext is a made-up distractor.

Memory hook: "…Web" = web-only. Xml/FileSystemXml/AnnotationConfig = standalone.
Q31 & Q50 · SpEL

#{...} is a SpEL expression; ${...} is a property placeholder

#{...} = SpEL: reference beans #{@myBean.value}, call statics via #{T(java.lang.Math).random()}, read system props #{systemProperties['user.name']}, do arithmetic #{2*100}. ${...} = property placeholder resolved from the Environment/properties files. A bare # with @ references a Spring bean. Key gotcha: a @Value("#{...random...}") is evaluated ONCE at bean creation — the field keeps that value forever. For a fresh value per call, compute it in the method body.

Memory hook: #{} = SpEL (beans, T(), systemProperties, maths) · ${} = property. @Value evaluates once.
Q38 · Bean instantiation order

Change creation order with @Lazy or @DependsOn — NOT @Order

@DependsOn("other") forces another bean to be created first; @Lazy defers a bean until first use. @Order is the trap — it only ranks beans within a collection (lists of filters, event listeners), it does not affect container instantiation order. @Import pulls in config classes but doesn't order bean creation.

Memory hook: @DependsOn / @Lazy = when a bean is built. @Order = position in a list, not creation order.
Q57 · Scopes outside web

Only singleton and prototype work in non-web apps

singleton (default, one per container) and prototype (new instance every request) work in any context. request, session, application, websocket need a web-aware context — using them standalone throws IllegalStateException at runtime.

Memory hook: singleton + prototype = anywhere. The other four = web only.

② Data Management & Transactions 7 misses

Q4 · Propagation

Set propagation on @Transactional OR programmatically on a TransactionDefinition

Two valid ways: declaratively via @Transactional(propagation = Propagation.REQUIRES_NEW), or programmatically via def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW) / a TransactionTemplate. There is no global property (spring.propagation.mode), no env var, and no PropagationMode bean — all distractors. Remember the defaults: REQUIRED (join or start); REQUIRES_NEW (suspend outer, start independent); NESTED (savepoint); MANDATORY (must already have one).

Memory hook: Propagation lives on @Transactional or a TransactionDefinition — never a global setting.
Q15 · Enabling declarative transactions

Three ingredients: @EnableTransactionManagement + a PlatformTransactionManager bean + @Transactional

Transaction management is not on by default in plain Spring. You need all three: (1) @EnableTransactionManagement on a @Configuration class (registers the AOP interceptor); (2) a PlatformTransactionManager bean (e.g. DataSourceTransactionManager, JpaTransactionManager); (3) @Transactional on the methods/classes. Spring Boot auto-supplies (1) and (2) — but you still write (3).

Memory hook: Enable + Manager bean + @Transactional. Miss any one → no transactions (silently).
Q22 · Terminology

Transactions within a single resource are Local Transactions

Local transactions span a single resource (one database) and are managed by that resource — no JTA / external coordinator. Contrast with global (distributed) transactions across multiple resources, which need JTA. "Scoped / Confined / Internal Transactions" are all made-up terms.

Memory hook: Single resource = Local · Multiple resources = Global (JTA).
Q24 · Rollback rules

By default, RuntimeException and Error roll back — checked exceptions do NOT

Spring's default: rollback on unchecked exceptions (RuntimeException + subclasses) and Error. Checked exceptions (IOException, SQLException) do not roll back by default. Override with @Transactional(rollbackFor = IOException.class) (or noRollbackFor).

Memory hook: Unchecked + Error → rollback. Checked → commit (unless rollbackFor).
Q49 · Supported tx APIs

Spring supports JDBC, JPA, Hibernate, JTA — not JDO

Spring's transaction abstraction integrates with Hibernate, JPA, JTA (distributed) and plain JDBC (via DataSourceTransactionManager). JDO is no longer supported — the org.springframework.orm.jdo package (incl. JdoTransactionManager) was removed in Spring Framework 5.0.

Memory hook: JDBC · JPA · Hibernate · JTA — yes. JDO — gone since Spring 5.
Q47 · Custom DataSource

Provide a custom DataSource by declaring your own @Bean

Define a @Bean of type DataSource in a @Configuration class. Because DataSourceAutoConfiguration is guarded by @ConditionalOnMissingBean, Spring Boot's default backs off and uses yours. You don't edit pom.xml or "disable" anything.

Memory hook: Your @Bean DataSource wins — auto-config backs off via @ConditionalOnMissingBean.
Q60 · JDBC auto-config

DataSourceDataSourceAutoConfiguration; JdbcTemplateJdbcTemplateAutoConfiguration

These beans come from auto-configuration classes shipped in spring-boot-autoconfigure — the developer writes nothing. DataSourceAutoConfiguration picks the pool (HikariCP by default), gated by @ConditionalOnClass + @ConditionalOnMissingBean. JdbcTemplateAutoConfiguration adds JdbcTemplate / NamedParameterJdbcTemplate, gated by @ConditionalOnSingleCandidate(DataSource.class) — so two DataSource beans without @Primary silently disables your JdbcTemplate. Registered via spring.factories (≤2.6) or AutoConfiguration.imports (2.7+).

Memory hook: Auto-config classes provide these beans, not your @Bean. Two DataSources + no @Primary = no JdbcTemplate.

③ Testing 4 misses

Q34 · @WebMvcTest — excluded beans

@WebMvcTest loads the web tier only — no @Component, no @ConfigurationProperties

Loaded: @Controller/@RestController, @ControllerAdvice, @JsonComponent, filters, converters — plus auto-configured MockMvc. NOT loaded: plain @Component, @Service, @Repository, and @ConfigurationProperties beans. Supply the missing collaborators with @MockBean (or @EnableConfigurationProperties for the properties bean).

Memory hook: @WebMvcTest = web tier only. @Component & @ConfigurationProperties are OUT.
Q42 · @WebMvcTest — supported forms

@WebMvcTest tests all / one / a subset of controllers — never plain components

Valid uses: @WebMvcTest (all discovered controllers), @WebMvcTest(MyController.class) (one controller in isolation), @WebMvcTest({A.class, B.class}) (a subset). It is a web slice, so it can never test a plain @Component in isolation — use a unit test or @SpringBootTest for that.

Memory hook: @WebMvcTest scopes to controllers (all / one / subset). Not for @Component.
Q52 · @DataJpaTest is transactional

@DataJpaTest methods are transactional and roll back by default

Yes — every @DataJpaTest method runs in a transaction that is rolled back at the end, keeping the DB clean between tests. It also configures only JPA components (entities, repositories, TestEntityManager) and uses an in-memory H2 DB by default. To keep changes, add @Rollback(false) or @Commit.

Memory hook: @DataJpaTest = transactional + auto-rollback + in-memory DB.
Q53 · Test property files

Point a test at a property file with @TestPropertySource

@TestPropertySource(locations = "classpath:test.properties") is the test-specific, highest-priority way to supply properties in a test. @PropertySource is for regular @Configuration (not test-specific). Also useful: src/test/resources/application.properties overrides main props, and @ActiveProfiles("test") loads application-test.properties.

Memory hook: Test props → @TestPropertySource (highest priority in tests).

④ Spring Boot & Actuator 2 misses

Q5 · Actuator defaults

Enabled ≠ exposed — every endpoint except shutdown is enabled, but only health/info are exposed over HTTP

Two separate concerns. Enablement: all endpoints are enabled by default except shutdown. HTTP exposure: only health (and historically info) are exposed over the web by default — the /actuator discovery page lists what's exposed. To reach /beans, /env, /metrics etc. over HTTP you must add them to management.endpoints.web.exposure.include. So /beans being "not provided out of the box" is about exposure, not enablement.

Memory hook: All endpoints enabled (except shutdown); only health/info exposed over HTTP. Expose more via web.exposure.include.
Q13 · Auto-configuration mechanics

Auto-config is driven by spring.factories candidates + @Conditional annotations

The two correct facts: auto-config classes are listed in META-INF/spring.factories (Boot ≤2.6) / AutoConfiguration.imports (Boot 2.7+) and processed at startup; and they use @Conditional annotations (@ConditionalOnClass, @ConditionalOnBean, @ConditionalOnMissingBean) to decide when to apply. Also true: auto-config runs after user beans (so your beans win), and it can trigger on a bean being present OR missing — not one or the other.

Memory hook: Listed in spring.factories + gated by @Conditional. Runs AFTER your beans, so you always win.

Your close-the-gap checklist — attempt #2

The 20 facts, one line each — cover this list from memory before the next go
Do this next Transactions cost you the most this round — re-read Lesson 9 · Transactions and Lesson 13 · Testing, then take the Full Mock Exam again. You only need +6. Come back here on any repeat miss.
I'm your teacher — ask me anything. Want a full propagation-behaviour drill (REQUIRED vs REQUIRES_NEW vs NESTED), or a side-by-side of the test slices (@WebMvcTest / @DataJpaTest / @SpringBootTest)? Just ask. Say "quiz me on the 20" for a rapid-fire mixed round.
← Review #1 Retake the Mock Exam →