Spring Boot is an open-source Java-based framework used to create microservices and standalone Spring applications with minimal configuration. It simplifies the bootstrapping and development of new Spring applications.
Spring Boot Anti-Patterns Overview
Using @Autowired on Fields
Not Using Configuration Properties
@ConfigurationProperties
to externalize configuration.Misusing @Transactional
@Transactional
can lead to unexpected rollbacks or transaction leaks. Be mindful of transaction boundaries and separate transactional operations from non-transactional ones.Not Using Spring Boot Starters
Not Using Spring Data Repositories
Not Using Proper Exception Handling
@ControllerAdvice
and @ExceptionHandler
to handle exceptions globally.Not Using Spring Profiles
Not Using Spring Boot Actuator
Not Using Spring Security Properly
Not Using Spring Boot Testing Features
@SpringBootTest
, @WebMvcTest
, and @DataJpaTest
for more effective testing.Not Using Spring Boot DevTools
Not Using Spring Boot Caching
@Cacheable
, @CachePut
, and @CacheEvict
for declarative caching.Not Using Spring Boot Validation
@Valid
, @NotNull
, @Size
, etc., for declarative validation.Not Using Spring Boot Actuator for Health Checks