Spring Boot in Action Skill
Apply the practices from Craig Walls' "Spring Boot in Action" to review existing code and write new Spring Boot applications. This skill operates in two modes: Review Mode (analyze code for violations of Spring Boot idioms) and Write Mode (produce clean, idiomatic Spring Boot from scratch).
The core philosophy: Spring Boot removes boilerplate through auto-configuration, starter dependencies, and sensible defaults. Fight the framework only when necessary — and when you do, prefer application.properties over code.
Reference Files
practices-catalog.md — Before/after examples for auto-configuration, starters, properties, profiles, security, testing, Actuator, and deployment
How to Use This Skill
Before responding, read practices-catalog.md for the topic at hand. For configuration issues read the properties/profiles section. For test code read the testing section. For a full review, read all sections.
Mode 1: Code Review
When the user asks you to review Spring Boot code, follow this process:
Step 1: Identify the Layer
Determine whether the code is a controller, service, repository, configuration class, or test. Review focus shifts by layer.
Step 2: Analyze the Code
Check these areas in order of severity:
Auto-Configuration (Ch 2, 3): Is auto-configuration being fought manually? Look for @Bean definitions that replicate what Spring Boot already provides (DataSource, Jackson, Security, etc.). Remove manual config where auto-config suffices.
Starter Dependencies (Ch 2): Are dependencies declared individually instead of using starters? spring-boot-starter-web, spring-boot-starter-data-jpa, spring-boot-starter-security etc. bundle correct transitive dependencies and version-manage them.
Externalized Configuration (Ch 3): Are values hardcoded that belong in application.properties? Ports, URLs, credentials, timeouts should all be externalized. Use @ConfigurationProperties for type-safe config objects; use @Value only for single values.
Profiles (Ch 3): Is environment-specific config (dev DB vs prod DB) handled with if statements or system properties? Use @Profile and application-{profile}.properties instead.
Security (Ch 3): Is WebSecurityConfigurerAdapter extended when simple property-based config would suffice? Is HTTP Basic enabled in production? Are actuator endpoints exposed without auth?
Testing (Ch 4):
- Use
@SpringBootTest for full integration tests, not raw new MyService()
- Use
@WebMvcTest for controller-only tests (no full context)
- Use
@DataJpaTest for repository tests (in-memory DB, no web layer)
- Use
MockMvc for controller assertions without starting a server
- Use
@MockBean to replace real beans with mocks in slice tests
- Avoid
@SpringBootTest(webEnvironment = RANDOM_PORT) unless testing the full HTTP stack
Actuator (Ch 7): Is the application missing health/metrics endpoints? Is /actuator fully exposed without security? Are custom health indicators implemented for critical dependencies?
Deployment (Ch 8): Is spring.profiles.active set for production? Is database migration (Flyway/Liquibase) configured? Is the app packaged as a self-contained JAR (preferred) or WAR?
General Idioms:
- Constructor injection over field injection (
@Autowired on fields)
@RestController = @Controller + @ResponseBody — use it for REST APIs
- Return
ResponseEntity<T> from controllers when status codes matter
Optional<T> from repository methods, never null
Step 3: Report Findings
For each issue, report:
- Chapter reference (e.g., "Ch 3: Externalized Configuration")
- Location in the code
- What's wrong (the anti-pattern)
- How to fix it (the Spring Boot idiomatic way)
- Priority: Critical (security/bugs), Important (maintainability), Suggestion (polish)
Step 4: Provide Fixed Code
Offer a corrected version with comments explaining each change.
Mode 2: Writing New Code
When the user asks you to write new Spring Boot code, apply these core principles:
Project Bootstrap (Ch 1, 2)
Start with Spring Initializr (Ch 1). Use start.spring.io or spring init CLI. Select starters upfront — don't add raw dependencies manually.
Use starters, not individual dependencies (Ch 2). spring-boot-starter-web includes Tomcat, Spring MVC, Jackson, and logging at compatible versions. Never declare spring-webmvc + jackson-databind + tomcat-embed-core separately.
The main class is the only required boilerplate (Ch 2):
@SpringBootApplication
public class MyApp {
public static void main(String[] args) {
SpringApplication.run(MyApp.class, args);
}
}
@SpringBootApplication = @Configuration + @EnableAutoConfiguration + @ComponentScan.
Configuration (Ch 3)
Externalize all environment-specific values (Ch 3). Nothing deployment-specific belongs in code. Use application.properties / application.yml for defaults.
Use @ConfigurationProperties for grouped config (Ch 3). Bind a prefix to a POJO — type-safe, IDE-friendly, testable:
@ConfigurationProperties(prefix = "app.mail")
@Component
public class MailProperties {
private String host;
private int port = 25;
// getters + setters
}
Use profiles for environment differences (Ch 3). application-dev.properties overrides application.properties when spring.profiles.active=dev. Never use if (env.equals("production")) in code.
Override auto-configuration surgically (Ch 3). Use spring.* properties first. Only define a @Bean when properties are insufficient. Annotate with @ConditionalOnMissingBean if providing a fallback.
Customize error pages declaratively (Ch 3). Place error/404.html, error/500.html in src/main/resources/templates/error/. No custom ErrorController needed for basic cases.
Security (Ch 3)
Extend WebSecurityConfigurerAdapter only for custom rules (Ch 3). For simple HTTP Basic with custom users, spring.security.user.name / spring.security.user.password properties suffice.
Always secure Actuator endpoints in production (Ch 7). Expose only health and info publicly; require authentication for env, beans, mappings, shutdown.
REST Controllers (Ch 2)
Use @RestController for API endpoints (Ch 2). Eliminates @ResponseBody on every method.
Return ResponseEntity<T> when HTTP status matters (Ch 2). ResponseEntity.ok(body), ResponseEntity.notFound().build(), ResponseEntity.status(201).body(created).
Use constructor injection, not field injection (Ch 2). Constructor injection makes dependencies explicit and enables testing without Spring context:
// Prefer this:
@RestController
public class BookController {
private final BookRepository repo;
public BookController(BookRepository repo) { this.repo = repo; }
}
Use Optional from repository queries (Ch 2). repo.findById(id).orElseThrow(() -> new ResponseStatusException(NOT_FOUND)).
Testing (Ch 4)
Match test slice to the layer being tested (Ch 4):
- Web layer only →
@WebMvcTest(MyController.class) + MockMvc
- Repository only →
@DataJpaTest
- Full app →
@SpringBootTest
- External service →
@MockBean to replace
Use MockMvc for controller assertions without starting a server (Ch 4):
mockMvc.perform(get("/books/1"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.title").value("Spring Boot in Action"));
Use @MockBean to isolate the unit under test (Ch 4). Replaces the real bean in the Spring context with a Mockito mock — cleaner than manual wiring.
Test security explicitly (Ch 4). Use .with(user("admin").roles("ADMIN")) or @WithMockUser to assert secured endpoints reject unauthenticated requests.
Actuator (Ch 7)
Enable Actuator in every production app (Ch 7). Add spring-boot-starter-actuator. At minimum expose health and info.
Write custom HealthIndicator for critical dependencies (Ch 7):
@Component
public class DatabaseHealthIndicator implements HealthIndicator {
@Override
public Health health() {
return canConnect() ? Health.up().build()
: Health.down().withDetail("reason", "timeout").build();
}
}
Add custom metrics via MeterRegistry (Ch 7). Counter, gauge, timer — gives Prometheus/Grafana visibility into business events.
Restrict Actuator exposure in production (Ch 7):
management.endpoints.web.exposure.include=health,info
management.endpoint.health.show-details=when-authorized
Deployment (Ch 8)
Package as an executable JAR by default (Ch 8). mvn package produces a fat JAR with embedded Tomcat. Run with java -jar app.jar. No application server needed.
Create a production profile (Ch 8). application-production.properties sets spring.datasource.url, disables dev tools, sets log levels to WARN.
Use Flyway or Liquibase for database migrations (Ch 8). Add spring-boot-starter-flyway; place scripts in classpath:db/migration/V1__init.sql. Never use spring.jpa.hibernate.ddl-auto=create in production.
Starter Cheat Sheet (Ch 2, Appendix B)
| Need |
Starter |
| REST API |
spring-boot-starter-web |
| JPA / Hibernate |
spring-boot-starter-data-jpa |
| Security |
spring-boot-starter-security |
| Observability |
spring-boot-starter-actuator |
| Testing |
spring-boot-starter-test |
| Thymeleaf views |
spring-boot-starter-thymeleaf |
| Redis cache |
spring-boot-starter-data-redis |
| Messaging |
spring-boot-starter-amqp |
| DB migration |
flyway-core |
Code Structure Template
// Main class (Ch 2)
@SpringBootApplication
public class LibraryApp {
public static void main(String[] args) {
SpringApplication.run(LibraryApp.class, args);
}
}
// Entity (Ch 2)
@Entity
public class Book {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String title;
private String isbn;
// constructors, getters, setters
}
// Repository (Ch 2)
public interface BookRepository extends JpaRepository<Book, Long> {
List<Book> findByTitleContainingIgnoreCase(String title);
}
// Service (Ch 2) — constructor injection
@Service
public class BookService {
private final BookRepository repo;
public BookService(BookRepository repo) { this.repo = repo; }
public Book findById(Long id) {
return repo.findById(id)
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
}
}
// Controller (Ch 2)
@RestController
@RequestMapping("/api/books")
public class BookController {
private final BookService service;
public BookController(BookService service) { this.service = service; }
@GetMapping("/{id}")
public ResponseEntity<Book> getBook(@PathVariable Long id) {
return ResponseEntity.ok(service.findById(id));
}
@PostMapping
public ResponseEntity<Book> createBook(@RequestBody Book book) {
Book saved = service.save(book);
URI location = URI.create("/api/books/" + saved.getId());
return ResponseEntity.created(location).body(saved);
}
}
// application.properties (Ch 3)
// spring.datasource.url=jdbc:postgresql://localhost/library
// spring.datasource.username=${DB_USER}
// spring.datasource.password=${DB_PASS}
// spring.jpa.hibernate.ddl-auto=validate
// management.endpoints.web.exposure.include=health,info
// application-dev.properties (Ch 3)
// spring.datasource.url=jdbc:h2:mem:library
// spring.jpa.hibernate.ddl-auto=create-drop
// logging.level.org.springframework=DEBUG
Priority of Practices by Impact
Critical (Security & Correctness)
- Ch 3: Never hardcode credentials — use
${ENV_VAR} in properties
- Ch 3: Secure Actuator endpoints —
env, beans, shutdown must require auth
- Ch 4: Test secured endpoints explicitly — assert 401/403 on unauthenticated requests
- Ch 8: Never use
ddl-auto=create in production — use Flyway/Liquibase
Important (Idiom & Maintainability)
- Ch 2: Constructor injection over
@Autowired field injection
- Ch 2:
@RestController over @Controller + @ResponseBody for APIs
- Ch 2:
Optional from repository, never null
- Ch 3:
@ConfigurationProperties over scattered @Value for grouped config
- Ch 3: Profiles for environment differences — not
if statements
- Ch 4:
@WebMvcTest for controller tests — not full @SpringBootTest
- Ch 7: Custom
HealthIndicator for each critical dependency
Suggestions (Polish)
- Ch 3: Custom error pages in
templates/error/ — no code needed
- Ch 7: Custom metrics via
MeterRegistry for business events
- Ch 8: Production profile disables dev tools, sets WARN log level
- Ch 2: Use
spring-boot-devtools in dev for live reload
1---2name: spring-boot-in-action3description: Write and review Spring Boot applications using practices from "Spring Boot in Action" by Craig Walls. Covers auto-configuration, starter dependencies, externalizing configuration with properties and profiles, Spring Security, testing with MockMvc and @SpringBootTest, Spring Actuator for production observability, and deployment strategies (JAR, WAR, Cloud Foundry). Use when building Spring Boot apps, configuring beans, writing integration tests, setting up health checks, or deploying to production. Trigger on: "Spring Boot", "Spring", "@SpringBootApplication", "auto-configuration", "application.properties", "application.yml", "@RestController", "@Service", "@Repository", "SpringBootTest", "Actuator", "starter", ".java files", "Maven", "Gradle".4---5
6# Spring Boot in Action Skill
7
8Apply the practices from Craig Walls' "Spring Boot in Action" to review existing code and write new Spring Boot applications. This skill operates in two modes: **Review Mode** (analyze code for violations of Spring Boot idioms) and **Write Mode** (produce clean, idiomatic Spring Boot from scratch).
9
10The core philosophy: Spring Boot removes boilerplate through **auto-configuration**, **starter dependencies**, and **sensible defaults**. Fight the framework only when necessary — and when you do, prefer `application.properties` over code.
11
12## Reference Files
13
14- `practices-catalog.md` — Before/after examples for auto-configuration, starters, properties, profiles, security, testing, Actuator, and deployment
15
16## How to Use This Skill
17
18**Before responding**, read `practices-catalog.md` for the topic at hand. For configuration issues read the properties/profiles section. For test code read the testing section. For a full review, read all sections.
19
20---
21
22## Mode 1: Code Review
23
24When the user asks you to **review** Spring Boot code, follow this process:
25
26### Step 1: Identify the Layer
27Determine whether the code is a controller, service, repository, configuration class, or test. Review focus shifts by layer.
28
29### Step 2: Analyze the Code
30
31Check these areas in order of severity:
32
331. **Auto-Configuration** (Ch 2, 3): Is auto-configuration being fought manually? Look for `@Bean` definitions that replicate what Spring Boot already provides (DataSource, Jackson, Security, etc.). Remove manual config where auto-config suffices.
34
352. **Starter Dependencies** (Ch 2): Are dependencies declared individually instead of using starters? `spring-boot-starter-web`, `spring-boot-starter-data-jpa`, `spring-boot-starter-security` etc. bundle correct transitive dependencies and version-manage them.
36
373. **Externalized Configuration** (Ch 3): Are values hardcoded that belong in `application.properties`? Ports, URLs, credentials, timeouts should all be externalized. Use `@ConfigurationProperties` for type-safe config objects; use `@Value` only for single values.
38
394. **Profiles** (Ch 3): Is environment-specific config (dev DB vs prod DB) handled with `if` statements or system properties? Use `@Profile` and `application-{profile}.properties` instead.
40
415. **Security** (Ch 3): Is `WebSecurityConfigurerAdapter` extended when simple property-based config would suffice? Is HTTP Basic enabled in production? Are actuator endpoints exposed without auth?
42
436. **Testing** (Ch 4):
44 - Use `@SpringBootTest` for full integration tests, not raw `new MyService()`
45 - Use `@WebMvcTest` for controller-only tests (no full context)
46 - Use `@DataJpaTest` for repository tests (in-memory DB, no web layer)
47 - Use `MockMvc` for controller assertions without starting a server
48 - Use `@MockBean` to replace real beans with mocks in slice tests
49 - Avoid `@SpringBootTest(webEnvironment = RANDOM_PORT)` unless testing the full HTTP stack
50
517. **Actuator** (Ch 7): Is the application missing health/metrics endpoints? Is `/actuator` fully exposed without security? Are custom health indicators implemented for critical dependencies?
52
538. **Deployment** (Ch 8): Is `spring.profiles.active` set for production? Is database migration (Flyway/Liquibase) configured? Is the app packaged as a self-contained JAR (preferred) or WAR?
54
559. **General Idioms**:
56 - Constructor injection over field injection (`@Autowired` on fields)
57 - `@RestController` = `@Controller` + `@ResponseBody` — use it for REST APIs
58 - Return `ResponseEntity<T>` from controllers when status codes matter
59 - `Optional<T>` from repository methods, never `null`
60
61### Step 3: Report Findings
62For each issue, report:
63- **Chapter reference** (e.g., "Ch 3: Externalized Configuration")
64- **Location** in the code
65- **What's wrong** (the anti-pattern)
66- **How to fix it** (the Spring Boot idiomatic way)
67- **Priority**: Critical (security/bugs), Important (maintainability), Suggestion (polish)
68
69### Step 4: Provide Fixed Code
70Offer a corrected version with comments explaining each change.
71
72---
73
74## Mode 2: Writing New Code
75
76When the user asks you to **write** new Spring Boot code, apply these core principles:
77
78### Project Bootstrap (Ch 1, 2)
79
801. **Start with Spring Initializr** (Ch 1). Use `start.spring.io` or `spring init` CLI. Select starters upfront — don't add raw dependencies manually.
81
822. **Use starters, not individual dependencies** (Ch 2). `spring-boot-starter-web` includes Tomcat, Spring MVC, Jackson, and logging at compatible versions. Never declare `spring-webmvc` + `jackson-databind` + `tomcat-embed-core` separately.
83
843. **The main class is the only required boilerplate** (Ch 2):
85 ```java
86 @SpringBootApplication
87 public class MyApp {
88 public static void main(String[] args) {
89 SpringApplication.run(MyApp.class, args);
90 }
91 }
92 ```
93 `@SpringBootApplication` = `@Configuration` + `@EnableAutoConfiguration` + `@ComponentScan`.
94
95### Configuration (Ch 3)
96
974. **Externalize all environment-specific values** (Ch 3). Nothing deployment-specific belongs in code. Use `application.properties` / `application.yml` for defaults.
98
995. **Use `@ConfigurationProperties` for grouped config** (Ch 3). Bind a prefix to a POJO — type-safe, IDE-friendly, testable:
100 ```java
101 @ConfigurationProperties(prefix = "app.mail")
102 @Component
103 public class MailProperties {
104 private String host;
105 private int port = 25;
106 // getters + setters
107 }
108 ```
109
1106. **Use profiles for environment differences** (Ch 3). `application-dev.properties` overrides `application.properties` when `spring.profiles.active=dev`. Never use `if (env.equals("production"))` in code.
111
1127. **Override auto-configuration surgically** (Ch 3). Use `spring.*` properties first. Only define a `@Bean` when properties are insufficient. Annotate with `@ConditionalOnMissingBean` if providing a fallback.
113
1148. **Customize error pages declaratively** (Ch 3). Place `error/404.html`, `error/500.html` in `src/main/resources/templates/error/`. No custom `ErrorController` needed for basic cases.
115
116### Security (Ch 3)
117
1189. **Extend `WebSecurityConfigurerAdapter` only for custom rules** (Ch 3). For simple HTTP Basic with custom users, `spring.security.user.name` / `spring.security.user.password` properties suffice.
119
12010. **Always secure Actuator endpoints in production** (Ch 7). Expose only `health` and `info` publicly; require authentication for `env`, `beans`, `mappings`, `shutdown`.
121
122### REST Controllers (Ch 2)
123
12411. **Use `@RestController` for API endpoints** (Ch 2). Eliminates `@ResponseBody` on every method.
125
12612. **Return `ResponseEntity<T>` when HTTP status matters** (Ch 2). `ResponseEntity.ok(body)`, `ResponseEntity.notFound().build()`, `ResponseEntity.status(201).body(created)`.
127
12813. **Use constructor injection, not field injection** (Ch 2). Constructor injection makes dependencies explicit and enables testing without Spring context:
129 ```java
130 // Prefer this:
131 @RestController
132 public class BookController {
133 private final BookRepository repo;
134 public BookController(BookRepository repo) { this.repo = repo; }
135 }
136 ```
137
13814. **Use `Optional` from repository queries** (Ch 2). `repo.findById(id).orElseThrow(() -> new ResponseStatusException(NOT_FOUND))`.
139
140### Testing (Ch 4)
141
14215. **Match test slice to the layer being tested** (Ch 4):
143 - Web layer only → `@WebMvcTest(MyController.class)` + `MockMvc`
144 - Repository only → `@DataJpaTest`
145 - Full app → `@SpringBootTest`
146 - External service → `@MockBean` to replace
147
14816. **Use `MockMvc` for controller assertions without starting a server** (Ch 4):
149 ```java
150 mockMvc.perform(get("/books/1"))
151 .andExpect(status().isOk())
152 .andExpect(jsonPath("$.title").value("Spring Boot in Action"));
153 ```
154
15517. **Use `@MockBean` to isolate the unit under test** (Ch 4). Replaces the real bean in the Spring context with a Mockito mock — cleaner than manual wiring.
156
15718. **Test security explicitly** (Ch 4). Use `.with(user("admin").roles("ADMIN"))` or `@WithMockUser` to assert secured endpoints reject unauthenticated requests.
158
159### Actuator (Ch 7)
160
16119. **Enable Actuator in every production app** (Ch 7). Add `spring-boot-starter-actuator`. At minimum expose `health` and `info`.
162
16320. **Write custom `HealthIndicator` for critical dependencies** (Ch 7):
164 ```java
165 @Component
166 public class DatabaseHealthIndicator implements HealthIndicator {
167 @Override
168 public Health health() {
169 return canConnect() ? Health.up().build()
170 : Health.down().withDetail("reason", "timeout").build();
171 }
172 }
173 ```
174
17521. **Add custom metrics via `MeterRegistry`** (Ch 7). Counter, gauge, timer — gives Prometheus/Grafana visibility into business events.
176
17722. **Restrict Actuator exposure in production** (Ch 7):
178 ```properties
179 management.endpoints.web.exposure.include=health,info
180 management.endpoint.health.show-details=when-authorized
181 ```
182
183### Deployment (Ch 8)
184
18523. **Package as an executable JAR by default** (Ch 8). `mvn package` produces a fat JAR with embedded Tomcat. Run with `java -jar app.jar`. No application server needed.
186
18724. **Create a production profile** (Ch 8). `application-production.properties` sets `spring.datasource.url`, disables dev tools, sets log levels to WARN.
188
18925. **Use Flyway or Liquibase for database migrations** (Ch 8). Add `spring-boot-starter-flyway`; place scripts in `classpath:db/migration/V1__init.sql`. Never use `spring.jpa.hibernate.ddl-auto=create` in production.
190
191---
192
193## Starter Cheat Sheet (Ch 2, Appendix B)
194
195| Need | Starter |
196|------|---------|
197| REST API | `spring-boot-starter-web` |
198| JPA / Hibernate | `spring-boot-starter-data-jpa` |
199| Security | `spring-boot-starter-security` |
200| Observability | `spring-boot-starter-actuator` |
201| Testing | `spring-boot-starter-test` |
202| Thymeleaf views | `spring-boot-starter-thymeleaf` |
203| Redis cache | `spring-boot-starter-data-redis` |
204| Messaging | `spring-boot-starter-amqp` |
205| DB migration | `flyway-core` |
206
207---
208
209## Code Structure Template
210
211```java
212// Main class (Ch 2)
213@SpringBootApplication
214public class LibraryApp {
215 public static void main(String[] args) {
216 SpringApplication.run(LibraryApp.class, args);
217 }
218}
219
220// Entity (Ch 2)
221@Entity
222public class Book {
223 @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
224 private Long id;
225 private String title;
226 private String isbn;
227 // constructors, getters, setters
228}
229
230// Repository (Ch 2)
231public interface BookRepository extends JpaRepository<Book, Long> {
232 List<Book> findByTitleContainingIgnoreCase(String title);
233}
234
235// Service (Ch 2) — constructor injection
236@Service
237public class BookService {
238 private final BookRepository repo;
239 public BookService(BookRepository repo) { this.repo = repo; }
240
241 public Book findById(Long id) {
242 return repo.findById(id)
243 .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
244 }
245}
246
247// Controller (Ch 2)
248@RestController
249@RequestMapping("/api/books")
250public class BookController {
251 private final BookService service;
252 public BookController(BookService service) { this.service = service; }
253
254 @GetMapping("/{id}")
255 public ResponseEntity<Book> getBook(@PathVariable Long id) {
256 return ResponseEntity.ok(service.findById(id));
257 }
258
259 @PostMapping
260 public ResponseEntity<Book> createBook(@RequestBody Book book) {
261 Book saved = service.save(book);
262 URI location = URI.create("/api/books/" + saved.getId());
263 return ResponseEntity.created(location).body(saved);
264 }
265}
266
267// application.properties (Ch 3)
268// spring.datasource.url=jdbc:postgresql://localhost/library
269// spring.datasource.username=${DB_USER}
270// spring.datasource.password=${DB_PASS}
271// spring.jpa.hibernate.ddl-auto=validate
272// management.endpoints.web.exposure.include=health,info
273
274// application-dev.properties (Ch 3)
275// spring.datasource.url=jdbc:h2:mem:library
276// spring.jpa.hibernate.ddl-auto=create-drop
277// logging.level.org.springframework=DEBUG
278```
279
280---
281
282## Priority of Practices by Impact
283
284### Critical (Security & Correctness)
285- Ch 3: Never hardcode credentials — use `${ENV_VAR}` in properties
286- Ch 3: Secure Actuator endpoints — `env`, `beans`, `shutdown` must require auth
287- Ch 4: Test secured endpoints explicitly — assert 401/403 on unauthenticated requests
288- Ch 8: Never use `ddl-auto=create` in production — use Flyway/Liquibase
289
290### Important (Idiom & Maintainability)
291- Ch 2: Constructor injection over `@Autowired` field injection
292- Ch 2: `@RestController` over `@Controller` + `@ResponseBody` for APIs
293- Ch 2: `Optional` from repository, never `null`
294- Ch 3: `@ConfigurationProperties` over scattered `@Value` for grouped config
295- Ch 3: Profiles for environment differences — not `if` statements
296- Ch 4: `@WebMvcTest` for controller tests — not full `@SpringBootTest`
297- Ch 7: Custom `HealthIndicator` for each critical dependency
298
299### Suggestions (Polish)
300- Ch 3: Custom error pages in `templates/error/` — no code needed
301- Ch 7: Custom metrics via `MeterRegistry` for business events
302- Ch 8: Production profile disables dev tools, sets WARN log level
303- Ch 2: Use `spring-boot-devtools` in dev for live reload