{"id":84340,"date":"2025-07-30T10:57:23","date_gmt":"2025-07-30T05:27:23","guid":{"rendered":"https:\/\/www.guvi.in\/blog\/?p=84340"},"modified":"2025-08-19T08:21:53","modified_gmt":"2025-08-19T02:51:53","slug":"spring-boot-3-x-interview-prep","status":"publish","type":"post","link":"https:\/\/www.guvi.in\/blog\/spring-boot-3-x-interview-prep\/","title":{"rendered":"Spring Boot 3.x Interview Prep: Latest 50 Questions for Backend Engineers"},"content":{"rendered":"\n<p>Are you preparing for backend interviews and feeling overwhelmed by the new features in Spring Boot 3.x? You\u2019re not alone. With the shift to Java 17+, Jakarta EE, and native image support, Spring Boot has evolved significantly, and so have the interview questions. <\/p>\n\n\n\n<p>Spring Boot is a powerful framework for building Java-based enterprise applications quickly and efficiently. This guide brings you 50 of the most relevant and frequently asked Spring Boot 3.x interview questions, covering everything from core concepts and auto-configuration to security, caching, microservices, and performance tuning.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>A. Core Spring Boot Questions<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. What is Spring Boot?<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"630\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-is-Spring-Boot_-1200x630.png\" alt=\"What is Spring Boot?\" class=\"wp-image-85075\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-is-Spring-Boot_-1200x630.png 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-is-Spring-Boot_-300x157.png 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-is-Spring-Boot_-768x403.png 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-is-Spring-Boot_-1536x806.png 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-is-Spring-Boot_-2048x1075.png 2048w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-is-Spring-Boot_-150x79.png 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<p><a href=\"https:\/\/www.guvi.in\/courses\/web-development\/spring-boot\/?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=spring-boot-3.x-interview-prep\" target=\"_blank\" rel=\"noreferrer noopener\">Spring Boot<\/a> is an open-source <a href=\"https:\/\/www.guvi.in\/blog\/best-java-frameworks-for-scalable-web-apps\/\" target=\"_blank\" rel=\"noreferrer noopener\">Java-based framework<\/a> used to create stand-alone, production-grade Spring applications with minimal configuration. It simplifies Spring application development by providing auto-configuration, embedded servers, and starter dependencies.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. What are the key features of Spring Boot?<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"630\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-are-the-key-features-of-Spring-Boot_-1200x630.png\" alt=\"key features of Spring Boot\" class=\"wp-image-85076\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-are-the-key-features-of-Spring-Boot_-1200x630.png 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-are-the-key-features-of-Spring-Boot_-300x157.png 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-are-the-key-features-of-Spring-Boot_-768x403.png 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-are-the-key-features-of-Spring-Boot_-1536x806.png 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-are-the-key-features-of-Spring-Boot_-2048x1075.png 2048w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-are-the-key-features-of-Spring-Boot_-150x79.png 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<ul>\n<li>Auto-configuration \u2013 Automatically configures Spring applications based on dependencies.<\/li>\n\n\n\n<li>Standalone \u2013 No need for external servers; includes embedded Tomcat, Jetty, or Undertow.<\/li>\n\n\n\n<li>Starter Dependencies \u2013 Simplifies dependency management (e.g., spring-boot-starter-web).<\/li>\n\n\n\n<li>Actuator \u2013 Provides production-ready features like health checks and metrics.<\/li>\n\n\n\n<li>Spring CLI \u2013 Allows rapid development using Groovy scripts.<\/li>\n\n\n\n<li>No XML Configuration \u2013 Uses Java-based or annotation-based configuration.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. What is the difference between Spring and Spring Boot?<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"630\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-is-the-difference-between-Spring-and-Spring-Boot_-1200x630.png\" alt=\"Difference between Spring and Spring Boot\" class=\"wp-image-85077\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-is-the-difference-between-Spring-and-Spring-Boot_-1200x630.png 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-is-the-difference-between-Spring-and-Spring-Boot_-300x158.png 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-is-the-difference-between-Spring-and-Spring-Boot_-768x403.png 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-is-the-difference-between-Spring-and-Spring-Boot_-1536x806.png 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-is-the-difference-between-Spring-and-Spring-Boot_-2048x1075.png 2048w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/08\/What-is-the-difference-between-Spring-and-Spring-Boot_-150x79.png 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Spring<\/td><td>Spring Boot<\/td><\/tr><tr><td>Requires manual configuration.<\/td><td>Provides auto-configuration.<\/td><\/tr><tr><td>No embedded server; needs external setup.<\/td><td>Comes with embedded servers.<\/td><\/tr><tr><td>Developers must define dependencies manually.<\/td><td>Starter POMs simplify dependency management.<\/td><\/tr><tr><td>More boilerplate code.<\/td><td>Reduces boilerplate code.<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\"> Difference between Spring and Spring Boot<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">4. What is the latest version of Spring Boot?<\/h3>\n\n\n\n<p>As of 2025, Spring Boot 3.x is the latest stable release, based on Spring Framework 6.x and Java 17+.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. What are the system requirements for Spring Boot 3.x?<\/h3>\n\n\n\n<ul>\n<li><a href=\"https:\/\/jdk.java.net\/17\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Java 17+<\/a> (mandatory)<\/li>\n\n\n\n<li>Spring Framework 6.x<\/li>\n\n\n\n<li>Compatible with Jakarta EE 9+ (replaces javax with jakarta packages)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>B. Spring Boot Auto-Configuration &amp; Starters<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">6. What is Spring Boot Auto-Configuration?<\/h3>\n\n\n\n<p>Auto-configuration automatically configures the Spring application based on the dependencies present in the classpath. For example, if the H2 database is in the classpath, Spring Boot auto-configures an in-memory database.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">7. How does Spring Boot Auto-Configuration work?<\/h3>\n\n\n\n<ul>\n<li>It scans the classpath for dependencies.<\/li>\n\n\n\n<li>Uses @Conditional annotations (e.g., @ConditionalOnClass, @ConditionalOnMissingBean) to decide which beans to configure.<\/li>\n\n\n\n<li>Defined in META-INF\/spring\/org.springframework.boot.autoconfigure.AutoConfiguration.imports (Spring Boot 3.x).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">8. What are Spring Boot Starters?<\/h3>\n\n\n\n<p>Starters are dependency descriptors that bundle common dependencies. Examples:<\/p>\n\n\n\n<ul>\n<li>spring-boot-starter-web \u2013 For web applications.<\/li>\n\n\n\n<li>spring-boot-starter-data-jpa \u2013 For JPA and Hibernate.<\/li>\n\n\n\n<li>spring-boot-starter-test \u2013 For testing.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">9. How to exclude auto-configuration classes?<\/h3>\n\n\n\n<p>Use @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) or in application.properties:<\/p>\n\n\n\n<p><code>spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>C. Spring Boot Annotations<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">10. What is @SpringBootApplication?<\/h3>\n\n\n\n<p>It is a combination of:<\/p>\n\n\n\n<ul>\n<li>@Configuration \u2013 Marks the class as a configuration class.<\/li>\n\n\n\n<li>@EnableAutoConfiguration \u2013 Enables auto-configuration.<\/li>\n\n\n\n<li>@ComponentScan \u2013 Scans for components in the package.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">11. What is @RestController vs @Controller?<\/h3>\n\n\n\n<ul>\n<li>@Controller \u2013 Used for traditional Spring MVC (returns view names).<\/li>\n\n\n\n<li>@RestController = @Controller + @ResponseBody (returns JSON\/XML responses directly).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">12. What is @RequestMapping vs @GetMapping\/@PostMapping?<\/h3>\n\n\n\n<ul>\n<li>@RequestMapping \u2013 Generic mapping (supports all HTTP methods).<\/li>\n\n\n\n<li>@GetMapping, @PostMapping \u2013 Shortcut annotations for specific HTTP methods.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">13. What is @Autowired?<\/h3>\n\n\n\n<p>Used for dependency injection. Spring automatically injects the required beans.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">14. What is @Bean?<\/h3>\n\n\n\n<p>Used in configuration classes to define a Spring bean:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Bean\npublic RestTemplate restTemplate() {\n&nbsp; &nbsp; return new RestTemplate();\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>D. Spring Boot Properties &amp; Configuration<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">15. What is application.properties\/application.yml?<\/h3>\n\n\n\n<p>Files used to configure Spring Boot applications. Example:<\/p>\n\n\n\n<p><code>server.port=8081<\/code><\/p>\n\n\n\n<p><code>spring.datasource.url=jdbc:h2:mem:testdb<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">16. How to read custom properties in Spring Boot?<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Using @Value:\n\n@Value(\"${custom.property}\")\n\nprivate String customProperty;\n\nOr using @ConfigurationProperties:\n\n@ConfigurationProperties(prefix = \"app\")\n\npublic class AppConfig {\n\n&nbsp;&nbsp;&nbsp;&nbsp;private String name;\n\n&nbsp;&nbsp;&nbsp;&nbsp;\/\/ Getters &amp; Setters\n\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">17. What are Spring Boot Profiles?<\/h3>\n\n\n\n<p>Profiles allow different configurations for different environments (e.g., dev, prod). Use application-{profile}.properties.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">18. How to activate a profile?<\/h3>\n\n\n\n<p>In application.properties:<br><code>spring.profiles.active=dev<br><\/code>Via command line:<br><code>java -jar app.jar --spring.profiles.active=prod<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>E. Spring Boot Actuator<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">19. What is Spring Boot Actuator?<\/h3>\n\n\n\n<p>A module that provides production-ready features like:<\/p>\n\n\n\n<ul>\n<li>Health checks (\/actuator\/health)<\/li>\n\n\n\n<li>Metrics (\/actuator\/metrics)<\/li>\n\n\n\n<li>Environment details (\/actuator\/env)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">20. How to enable the Actuator?<\/h3>\n\n\n\n<p>Add the dependency:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;dependency&gt;\n&nbsp; &nbsp; &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n&nbsp; &nbsp; &lt;artifactId&gt;spring-boot-starter-actuator&lt;\/artifactId&gt;\n&lt;\/dependency&gt;\nConfigure endpoints in application.properties:\nmanagement.endpoints.web.exposure.include=*<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>F. Spring Boot Database &amp; JPA<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">21. How to configure a database in Spring Boot?<\/h3>\n\n\n\n<p>Use application.properties: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>spring.datasource.url=jdbc:mysql:\/\/localhost:3306\/db\nspring.datasource.username=root\nspring.datasource.password=root\nspring.jpa.hibernate.ddl-auto=update<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">22. What is spring.jpa.hibernate.ddl-auto?<\/h3>\n\n\n\n<ul>\n<li>None \u2013 No schema generation.<\/li>\n\n\n\n<li>Update \u2013 Updates schema if needed.<\/li>\n\n\n\n<li>create \u2013 Creates schema on startup (drops old data).<\/li>\n\n\n\n<li>create-drop \u2013 Creates on startup, drops on shutdown.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">23. What is @Entity?<\/h3>\n\n\n\n<p>Marks a class as a JPA entity (maps to a database table).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">24. What is @Repository?<\/h3>\n\n\n\n<p>Used in DAO classes for database operations. Extends JpaRepository.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>G. Spring Boot Security<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">25. How to secure a Spring Boot application?<\/h3>\n\n\n\n<p>Add spring-boot-starter-security:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;<strong>dependency<\/strong>&gt;\n&nbsp; &nbsp; &lt;<strong>groupId<\/strong>&gt;org.springframework.boot&lt;\/<strong>groupId<\/strong>&gt;\n&nbsp; &nbsp; &lt;<strong>artifactId<\/strong>&gt;spring-boot-starter-security&lt;\/<strong>artifactId<\/strong>&gt;\n&lt;\/<strong>dependency<\/strong>&gt;<\/code><\/pre>\n\n\n\n<p>Configure security in a @Configuration class extending WebSecurityConfigurerAdapter (deprecated in Spring Boot 3.x) or using SecurityFilterChain.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>H. Spring Boot Testing<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">26. What is @SpringBootTest?<\/h3>\n\n\n\n<p>Used for integration testing (loads the full application context).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">27. What is @MockBean?<\/h3>\n\n\n\n<p>Used to mock a bean in the Spring context (useful in testing).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>I. Spring Boot REST API<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">28. How to create a REST API in Spring Boot?<\/h3>\n\n\n\n<ul>\n<li>Use @RestController.<\/li>\n\n\n\n<li>Define endpoints (@GetMapping, @PostMapping).<\/li>\n\n\n\n<li>Use @RequestBody for POST\/PUT requests.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">29. What is ResponseEntity?<\/h3>\n\n\n\n<p>A wrapper for HTTP responses (status code, headers, body).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>J. Spring Boot Exception Handling<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">30. How to handle exceptions in Spring Boot?<\/h3>\n\n\n\n<ul>\n<li>Use @ControllerAdvice for global exception handling.<\/li>\n\n\n\n<li>Use @ExceptionHandler to handle specific exceptions.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>K. Spring Boot Caching<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">31. How to enable caching in Spring Boot?<\/h3>\n\n\n\n<p>Add @EnableCaching and use @Cacheable on methods.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>L. Spring Boot Deployment<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">32. How to deploy a Spring Boot application?<\/h3>\n\n\n\n<ul>\n<li>As a JAR (embedded server): java -jar app.jar.<\/li>\n\n\n\n<li>As a WAR (external server like Tomcat).<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>M. Spring Boot Microservices<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">33. What is Spring Cloud?<\/h3>\n\n\n\n<p>A set of tools for building microservices (e.g., Eureka, Zuul, Config Server).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>N. Spring Boot Best Practices<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">34. What are Spring Boot&#8217;s best practices?<\/h3>\n\n\n\n<ul>\n<li>Use DTOs instead of entities in APIs.<\/li>\n\n\n\n<li>Follow layered architecture (Controller \u2192 Service \u2192 Repository).<\/li>\n\n\n\n<li>Use proper logging (SLF4J with Logback).<\/li>\n\n\n\n<li>Validate inputs (Bean Validation).<\/li>\n\n\n\n<li>Secure APIs (OAuth2, JWT).<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>O. Advanced Spring Boot Questions<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">35. What\u2019s new in Spring Boot 3.x?<\/h3>\n\n\n\n<ul>\n<li>Java 17+ baseline.<\/li>\n\n\n\n<li>Jakarta EE 9+ (replaced javax with jakarta).<\/li>\n\n\n\n<li>Improved Native Image Support (GraalVM).<\/li>\n\n\n\n<li>Enhanced Observability (Micrometer, OpenTelemetry).<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>P. Spring Boot Transactions<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">36. What is @Transactional in Spring Boot?<\/h3>\n\n\n\n<p>@Transactional ensures that a method executes within a database transaction. If an exception occurs, the transaction rolls back.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Transactional&nbsp;&nbsp;\n\npublic void transferMoney(Account from, Account to, double amount) {&nbsp;&nbsp;\n\n&nbsp;&nbsp;&nbsp;&nbsp;from.debit(amount);&nbsp;&nbsp;\n\n&nbsp;&nbsp;&nbsp;&nbsp;to.credit(amount);&nbsp;&nbsp;\n\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">37. What are the propagation behaviors in @Transactional?<\/h3>\n\n\n\n<ul>\n<li>REQUIRED (Default) \u2013 Uses existing transactions or creates a new one.<\/li>\n\n\n\n<li>REQUIRES_NEW \u2013 Always creates a new transaction.<\/li>\n\n\n\n<li>SUPPORTS \u2013 Runs in a transaction if one exists, else non-transactional.<\/li>\n\n\n\n<li>NOT_SUPPORTED \u2013 Executes non-transactionally.<\/li>\n\n\n\n<li>MANDATORY \u2013 Must run within an existing transaction (else throws an exception).<\/li>\n\n\n\n<li>NEVER \u2013 Must not run within a transaction (else throws an exception).<\/li>\n\n\n\n<li>NESTED \u2013 Creates a nested transaction (if supported by the database).<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Q. Spring Boot AOP (Aspect-Oriented Programming)<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">38. What is Spring AOP?<\/h3>\n\n\n\n<p>Spring AOP allows cross-cutting concerns (logging, security, transactions) to be modularized using aspects.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">39. What are the key AOP annotations?<\/h3>\n\n\n\n<ul>\n<li>@Aspect \u2013 Declares a class as an aspect.<\/li>\n\n\n\n<li>@Before \u2013 Runs before a method.<\/li>\n\n\n\n<li>@After \u2013 Runs after a method (success or failure).<\/li>\n\n\n\n<li>@Around \u2013 Wraps a method (can modify input\/output).<\/li>\n\n\n\n<li>@AfterReturning \u2013 Runs after successful execution.<\/li>\n\n\n\n<li>@AfterThrowing \u2013 Runs if an exception occurs.<\/li>\n<\/ul>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Aspect&nbsp;\n@Component&nbsp;\npublic class LoggingAspect {&nbsp;\n&nbsp; &nbsp; @Before(\"execution(* com.example.service.*.*(..))\")&nbsp;\n&nbsp; &nbsp; public void logBefore(JoinPoint joinPoint) {&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; System.out.println(\"Method called: \" + joinPoint.getSignature());&nbsp;\n&nbsp; &nbsp; }&nbsp;\n}&nbsp;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>R. Spring Boot Caching<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">40. How to enable caching in Spring Boot?<\/h3>\n\n\n\n<ol>\n<li>Add spring-boot-starter-cache:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;<strong>dependency<\/strong>&gt;&nbsp;\n&nbsp; &nbsp; &lt;<strong>groupId<\/strong>&gt;org.springframework.boot&lt;\/<strong>groupId<\/strong>&gt;&nbsp;\n&nbsp; &nbsp; &lt;<strong>artifactId<\/strong>&gt;spring-boot-starter-cache&lt;\/<strong>artifactId<\/strong>&gt;&nbsp;\n&lt;\/<strong>dependency<\/strong>&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Enable caching with @EnableCaching.\nUse @Cacheable on methods:\n@Cacheable(\"products\")&nbsp;\npublic Product getProductById(Long id) {&nbsp;\n&nbsp; &nbsp; return productRepository.findById(id).orElse(null);&nbsp;\n}&nbsp;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">41. What are the different cache providers supported?<\/h3>\n\n\n\n<ul>\n<li>Caffeine (Default in Spring Boot 3.x)<\/li>\n\n\n\n<li>EhCache<\/li>\n\n\n\n<li>Redis<\/li>\n\n\n\n<li>Hazelcast<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>S. Spring Boot Testing<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">42. What is @WebMvcTest?<\/h3>\n\n\n\n<p>Used for testing Spring MVC controllers (without loading the full application context).<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@WebMvcTest(ProductController.class)&nbsp;\npublic class ProductControllerTest {&nbsp;\n&nbsp; &nbsp; @Autowired&nbsp;\n&nbsp; &nbsp; private MockMvc mockMvc;&nbsp;\n\n&nbsp; &nbsp; @MockBean&nbsp;\n&nbsp; &nbsp; private ProductService productService;&nbsp;\n\n&nbsp; &nbsp; @Test&nbsp;\n&nbsp; &nbsp; public void testGetProduct() throws Exception {&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; when(productService.getProduct(1L)).thenReturn(new Product(1L, \"Laptop\"));&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; mockMvc.perform(get(\"\/products\/1\"))&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .andExpect(status().isOk());&nbsp;\n&nbsp; &nbsp; }&nbsp;\n}&nbsp;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">43. What is @DataJpaTest?<\/h3>\n\n\n\n<p>Used for testing JPA repositories (configures an in-memory database).<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@DataJpaTest&nbsp;\npublic class ProductRepositoryTest {&nbsp;\n&nbsp; &nbsp; @Autowired&nbsp;\n&nbsp; &nbsp; private TestEntityManager entityManager;&nbsp;\n\n&nbsp; &nbsp; @Autowired&nbsp;\n&nbsp; &nbsp; private ProductRepository productRepository;&nbsp;\n\n&nbsp; &nbsp; @Test&nbsp;\n&nbsp; &nbsp; public void testFindById() {&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; Product product = new Product(1L, \"Laptop\");&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; entityManager.persist(product);&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; assertThat(productRepository.findById(1L)).isPresent();&nbsp;\n&nbsp; &nbsp; }&nbsp;\n}&nbsp;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>T. Spring Boot Security (OAuth2 &amp; JWT)<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">44. How to implement JWT authentication in Spring Boot?<\/h3>\n\n\n\n<ol>\n<li>Add dependencies:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;<strong>dependency<\/strong>&gt;&nbsp;\n&nbsp; &nbsp; &lt;<strong>groupId<\/strong>&gt;org.springframework.boot&lt;\/<strong>groupId<\/strong>&gt;&nbsp;\n&nbsp; &nbsp; &lt;<strong>artifactId<\/strong>&gt;spring-boot-starter-security&lt;\/<strong>artifactId<\/strong>&gt;&nbsp;\n&lt;\/<strong>dependency<\/strong>&gt;&nbsp;\n&lt;<strong>dependency<\/strong>&gt;&nbsp;\n&nbsp; &nbsp; &lt;<strong>groupId<\/strong>&gt;io.jsonwebtoken&lt;\/<strong>groupId<\/strong>&gt;&nbsp;\n&nbsp; &nbsp; &lt;<strong>artifactId<\/strong>&gt;jjwt-api&lt;\/<strong>artifactId<\/strong>&gt;&nbsp;\n&nbsp; &nbsp; &lt;<strong>version<\/strong>&gt;0.11.5&lt;\/<strong>version<\/strong>&gt;&nbsp;\n&lt;\/<strong>dependency<\/strong>&gt;&nbsp;<\/code><\/pre>\n\n\n\n<p>2. Configure SecurityFilterChain:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Bean&nbsp;\npublic SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {&nbsp;\n&nbsp; &nbsp; http.csrf().disable()&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; .authorizeHttpRequests(auth -&gt; auth&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .requestMatchers(\"\/auth\/login\").permitAll()&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .anyRequest().authenticated())&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; .sessionManagement(sess -&gt; sess.sessionCreationPolicy(SessionCreationPolicy.STATELESS))&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; .addFilterBefore(jwtAuthFilter, UsernamePasswordAuthenticationFilter.class);&nbsp;\n&nbsp; &nbsp; return http.build();&nbsp;\n}&nbsp;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">45. What is OAuth2 in Spring Boot?<\/h3>\n\n\n\n<p>OAuth2 is an authorization framework that allows third-party apps to access user data without exposing credentials.<\/p>\n\n\n\n<p>Key components:<\/p>\n\n\n\n<ul>\n<li>Resource Server (e.g., REST API)<\/li>\n\n\n\n<li>Authorization Server (e.g., Keycloak, Okta)<\/li>\n\n\n\n<li>Client (e.g., Web\/Mobile App)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>U. Spring Boot Monitoring &amp; Observability<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">46. What is Micrometer in Spring Boot?<\/h3>\n\n\n\n<p>Micrometer is a metrics instrumentation library used for monitoring (supports Prometheus, Grafana, etc.).<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@RestController&nbsp;\npublic class MetricController {&nbsp;\n&nbsp; &nbsp; private final Counter requestCounter;&nbsp;\n\n&nbsp; &nbsp; public MetricController(MeterRegistry registry) {&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; requestCounter = registry.counter(\"api.requests.count\");&nbsp;\n&nbsp; &nbsp; }&nbsp;\n\n&nbsp; &nbsp; @GetMapping(\"\/hello\")&nbsp;\n&nbsp; &nbsp; public String hello() {&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; requestCounter.increment();&nbsp;\n&nbsp; &nbsp; &nbsp; &nbsp; return \"Hello!\";&nbsp;\n&nbsp; &nbsp; }&nbsp;\n}&nbsp;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">47. How to integrate Prometheus with Spring Boot?<\/h3>\n\n\n\n<ol>\n<li>Add dependencies:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;<strong>dependency<\/strong>&gt;&nbsp;\n&nbsp; &nbsp; &lt;<strong>groupId<\/strong>&gt;io.micrometer&lt;\/<strong>groupId<\/strong>&gt;&nbsp;\n&nbsp; &nbsp; &lt;<strong>artifactId<\/strong>&gt;micrometer-registry-prometheus&lt;\/<strong>artifactId<\/strong>&gt;&nbsp;\n&lt;\/<strong>dependency<\/strong>&gt;&nbsp;<\/code><\/pre>\n\n\n\n<p>2. Enable Prometheus endpoint in application.properties:<\/p>\n\n\n\n<p><code>management.endpoints.web.exposure.include=prometheus,health,metrics&nbsp;<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>V. Spring Boot Native Image (GraalVM)<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">48. What is Spring Native?<\/h3>\n\n\n\n<p>Spring Native allows compiling Spring Boot apps into native executables (using GraalVM) for faster startup (~100ms).<\/p>\n\n\n\n<p>How to use it?<\/p>\n\n\n\n<ol>\n<li>Add dependency:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;<strong>dependency<\/strong>&gt;&nbsp;\n&nbsp; &nbsp; &lt;<strong>groupId<\/strong>&gt;org.springframework.experimental&lt;\/<strong>groupId<\/strong>&gt;&nbsp;\n&nbsp; &nbsp; &lt;<strong>artifactId<\/strong>&gt;spring-native&lt;\/<strong>artifactId<\/strong>&gt;&nbsp;\n&nbsp; &nbsp; &lt;<strong>version<\/strong>&gt;0.12.1&lt;\/<strong>version<\/strong>&gt;&nbsp;\n&lt;\/<strong>dependency<\/strong>&gt;<\/code><\/pre>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; 2. Build a native image:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mvn spring-boot:build-image&nbsp;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>W. Spring Boot Best Practices<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">49. How to improve Spring Boot performance?<\/h3>\n\n\n\n<ul>\n<li>Use connection pooling (HikariCP).<\/li>\n\n\n\n<li>Enable caching (@Cacheable).<\/li>\n\n\n\n<li>Use Lombok to reduce boilerplate code.<\/li>\n\n\n\n<li>Avoid circular dependencies.<\/li>\n\n\n\n<li>Use asynchronous processing (@Async).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">50. What are the common pitfalls in Spring Boot?<\/h3>\n\n\n\n<ul>\n<li>Using @Autowired on fields (prefer constructor injection).<\/li>\n\n\n\n<li>Ignoring transaction management (leads to DB inconsistencies).<\/li>\n\n\n\n<li>Not handling exceptions properly (use @ControllerAdvice).<\/li>\n\n\n\n<li>Hardcoding configurations (use @ConfigurationProperties).<\/li>\n<\/ul>\n\n\n\n<p>If you want to learn more about Full-stack development and become well-versed in Backend Development, consider enrolling in GUVI\u2019s IIT-M Pravartak certified <a href=\"https:\/\/www.guvi.in\/zen-class\/full-stack-development-course\/?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=spring-boot-3.x-interview-prep\" target=\"_blank\" rel=\"noreferrer noopener\">Full-Stack Development Course <\/a>with AI Tools, which provides you with all the resources and guidance to have a successful full-stack career!&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>In conclusion, mastering Spring Boot 3.x means more than just knowing how to build an API\u2014it\u2019s about understanding how the framework works under the hood, how it\u2019s changing with modern Java, and how to architect scalable, secure applications. <\/p>\n\n\n\n<p>Whether you&#8217;re a junior developer brushing up or a seasoned engineer targeting senior roles, these questions cover the depth and breadth you\u2019ll need to walk into your next backend interview with confidence.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you preparing for backend interviews and feeling overwhelmed by the new features in Spring Boot 3.x? You\u2019re not alone. With the shift to Java 17+, Jakarta EE, and native image support, Spring Boot has evolved significantly, and so have the interview questions. Spring Boot is a powerful framework for building Java-based enterprise applications quickly [&hellip;]<\/p>\n","protected":false},"author":40,"featured_media":85073,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[720],"tags":[],"views":"2761","authorinfo":{"name":"Lavish Jain","url":"https:\/\/www.guvi.in\/blog\/author\/lavish-jain\/"},"thumbnailURL":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/07\/Spring-Boot-3.x-Interview-Prep-300x116.png","jetpack_featured_media_url":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/07\/Spring-Boot-3.x-Interview-Prep.png","_links":{"self":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/84340"}],"collection":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/comments?post=84340"}],"version-history":[{"count":6,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/84340\/revisions"}],"predecessor-version":[{"id":85078,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/84340\/revisions\/85078"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media\/85073"}],"wp:attachment":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media?parent=84340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/categories?post=84340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/tags?post=84340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}