0% found this document useful (0 votes)
1 views

Spring_Boot_Interview_Problems

The document explains the auto-configuration in Spring Boot, detailing how it works with annotations like @EnableAutoConfiguration and @SpringBootApplication, and how it can be customized. It also covers the use of Spring profiles for environment-specific configurations, common performance bottlenecks in Spring Boot applications, and strategies for monitoring and managing applications in production using Spring Boot Actuator. Key solutions include optimizing bean initialization, leveraging reactive design, and integrating with monitoring tools.

Uploaded by

pbecic
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Spring_Boot_Interview_Problems

The document explains the auto-configuration in Spring Boot, detailing how it works with annotations like @EnableAutoConfiguration and @SpringBootApplication, and how it can be customized. It also covers the use of Spring profiles for environment-specific configurations, common performance bottlenecks in Spring Boot applications, and strategies for monitoring and managing applications in production using Spring Boot Actuator. Key solutions include optimizing bean initialization, leveraging reactive design, and integrating with monitoring tools.

Uploaded by

pbecic
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Spring Boot for Strong Senior Developers

How does Spring Boot auto-configuration work and how can it be customized?
 Spring Boot uses @EnableAutoConfiguration and @SpringBootApplication to configure
beans automatically.
 Auto-configuration classes are loaded using SpringFactoriesLoader from
spring.factories.
 Customization options:
 Override specific beans by declaring them explicitly.
 Use @ConditionalOn... annotations to control auto-configuration behavior.
 Disable auto-config classes via @EnableAutoConfiguration(exclude = ...).
 Auto-config is context-aware and conditional based on classpath, properties, and bean
presence.

What is the role of @SpringBootApplication and how does it simplify


configuration?
 @SpringBootApplication is a meta-annotation that combines:
 @Configuration — marks the class as a source of bean definitions.
 @EnableAutoConfiguration — enables Spring Boot’s auto-configuration mechanism.
 @ComponentScan — enables component scanning for the package and sub-packages.
 Simplifies project bootstrap and reduces boilerplate configuration.

How do Spring Boot profiles work and how can they be used for environment-
specific configuration?
 Spring profiles allow grouping of beans and properties for different environments (e.g.,
dev, test, prod).
 Activation:
 Set via application.properties (spring.profiles.active=dev), environment variable, or
command-line args.
 Use @Profile annotation on beans or configurations.
 Support for profile-specific property files:
 application-dev.properties, application-prod.yml, etc.
 Profiles help isolate environment concerns and avoid hardcoded differences.

What are common performance bottlenecks in Spring Boot applications and


how would you address them?
 Common issues:
 Excessive bean initialization or complex dependency trees.
 Improper use of blocking calls in WebFlux.
 Inefficient DB queries or N+1 select problems.
 Large startup time due to heavy autowiring or scanning.
 Solutions:
 Use lazy-init where applicable.
 Profile bean load time with spring-boot-actuator and devtools.
 Optimize JPA/Hibernate with fetch joins or batch sizes.
 Leverage reactive design for I/O-heavy workloads.

How do you monitor and manage a Spring Boot application in production?


 Use Spring Boot Actuator to expose management endpoints.
 Endpoints include:
 /actuator/health, /actuator/metrics, /actuator/beans, /actuator/env
 Integrate with monitoring tools:
 Micrometer for metrics (supports Prometheus, Datadog, etc.).
 Log aggregation via ELK or Loki.
 Security:
 Restrict actuator access with Spring Security or management server port configuration.
 Use readiness/liveness probes in Kubernetes for health checks.

You might also like