1---2name: java-backend3description: Use when developing Java backend applications — Spring Boot 3.x (auto-configuration, starters, actuator, profiles), Spring Security (OAuth2/OIDC, JWT, method security), Spring Data JPA/Hibernate (entity mapping, repositories, query methods, N+1 prevention), REST API design (controllers, validation, error handling, HATEOAS), microservices patterns (service discovery, circuit breaker, API gateway, config server), testing (JUnit 5, Mockito, Testcontainers, MockMvc), build tools (Maven/Gradle), and Jakarta EE patterns. Part of the java-* skill family.4---56# Java Backend Development78Covers Spring Boot 3.x, Spring Security, Spring Data JPA, REST APIs, microservices, messaging, testing, build tooling, performance, and Jakarta EE patterns. For IBM WebSphere/Liberty deployments see `ibm-websphere`. For IBM MQ messaging see `ibm-mq`. For database administration see `rhel-databases` or `ubuntu-databases`.910<HARD-RULE>11Always use DTOs for API request/response — never expose JPA entities directly. Exposing entities leaks internal schema, breaks encapsulation, and causes lazy loading exceptions during serialization. Use MapStruct or manual mapping between entities and DTOs.12</HARD-RULE>1314<HARD-RULE>15Never use @Transactional on private methods — Spring proxies only intercept public methods. A @Transactional annotation on a private method silently does nothing; the code runs without a transaction boundary and data integrity is at risk.16</HARD-RULE>1718<HARD-RULE>19Always define fetch strategy explicitly on JPA relationships — the default EAGER fetch on @ManyToOne and @OneToOne causes N+1 queries that destroy performance at scale. Set fetch = FetchType.LAZY on every relationship and use @EntityGraph or JOIN FETCH for controlled eager loading.20</HARD-RULE>2122<HARD-RULE>23Never catch and swallow exceptions in the service layer without logging — silent catch blocks make production debugging impossible. At minimum log the exception at ERROR level with full stack trace. Prefer letting exceptions propagate to a @ControllerAdvice handler.24</HARD-RULE>2526---2728## Reference Files2930Detailed code examples, patterns, and configuration are in the reference files below. Read the relevant file when working on that area.3132| File | Covers |33|---|---|34| [build-performance-jakartaee.md](build-performance-jakartaee.md) | build and deployment (Maven/Gradle, multi-stage Docker, Jib, GraalVM native image), performance and observability (connection pooling, caching, Micrometer metrics, structured logging), and Jakarta EE patterns |35| [messaging-testing.md](messaging-testing.md) | messaging (Kafka producer/consumer, RabbitMQ, Spring Events, outbox pattern) and testing (JUnit 5, Mockito, MockMvc, @DataJpaTest, Testcontainers, contract testing) |36| [rest-api-design.md](rest-api-design.md) | controllers with validation and pagination, DTO pattern with MapStruct, global exception handling with @ControllerAdvice, and HATEOAS |37| [service-microservices.md](service-microservices.md) | service layer patterns (transactions, retry, caching, events), microservices (service discovery, circuit breaker/Resilience4j, API gateway, distributed tracing, config server) |38| [spring-data-jpa.md](spring-data-jpa.md) | entity mapping, repository interfaces, query methods and @Query, projections, N+1 prevention (@EntityGraph, JOIN FETCH), auditing, and Flyway migrations |39| [spring-fundamentals.md](spring-fundamentals.md) | project structure, application entry point, multi-profile YAML configuration, @ConfigurationProperties, and Actuator endpoints |40| [spring-security.md](spring-security.md) | SecurityFilterChain configuration, JWT authentication with OAuth2 resource server, method-level security (@PreAuthorize), CORS configuration, and CSRF handling |4142---4344---4546## Anti-Patterns4748| Anti-Pattern | Why It Fails | Correct Approach |49|---|---|---|50| N+1 query problem with JPA lazy loading | Fetching a list then accessing each entity's relation fires N additional queries; destroys performance | Use JOIN FETCH in JPQL, @EntityGraph, or batch size hints; monitor query count with Hibernate statistics |51| Catching generic Exception everywhere | Swallows unexpected errors; masks bugs; makes debugging impossible; violates fail-fast principle | Catch specific exceptions; let unexpected ones propagate to global handler; log with full stack trace |52| Not using constructor injection in Spring | Field injection hides dependencies, prevents immutability, makes testing harder, and breaks with final fields | Use constructor injection (Lombok @RequiredArgsConstructor); makes dependencies explicit and testable |53| Blocking calls in reactive/WebFlux endpoints | One blocking call exhausts the event loop thread pool; entire application stops responding | Use .subscribeOn(Schedulers.boundedElastic()) for blocking calls; prefer non-blocking drivers |54| Exposing JPA entities directly as REST responses | Tight coupling between DB schema and API; any schema change breaks clients; serialization of lazy proxies causes errors | Use DTOs/records for API responses; map entities to DTOs in a service layer |5556---5758## Related Skills5960| Domain | Skill |61|---|---|62| IBM WebSphere/Liberty deployment | `ibm-websphere` |63| IBM MQ messaging | `ibm-mq` |64| PostgreSQL/MySQL/Redis administration | `rhel-databases`, `ubuntu-databases` |65| Docker containerization | `docker-fundamentals`, `docker-admin` |66| Python Flask/FastAPI alternative | `python-flask-developer` |67| Authentication and security patterns | `python-auth-security` |68| CI/CD with Docker | `docker-cicd` |69| Microservices architecture | `saas-architecture` |70| MongoDB (NoSQL alternative) | `mongodb` |71| DB2 database integration | `db2-rhel`, `db2-mainframe` |