Return to site

🍃 Spring Boot Interview Questions

· java

𝗤𝟭. What Is Spring Boot and What Are Its Main Features? 🤔

framework for rapid application development: starters, auto-config, actuator, security, logging.

𝗤𝟮. What Are the Differences Between Spring and Spring Boot? ✊

Spring Boot makes configuring a Spring application a breeze.

𝗤𝟯. How Can We Set Up a Spring Boot Application With Maven? ⚙️

Inherit from the spring-boot-starter-parent maven project.

𝗤𝟰. What Is Spring Initializr? 🚀

It creates a skeleton project for us.

𝗤𝟱. What Spring Boot Starters Are Available Out There? 📃

There are over 50 starters: core, aop, jpa, security, test, web...

𝗤𝟲. How to Disable a Specific Auto-Configuration? ❌

Exlude it: @EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class).

𝗤𝟳. How to Register a Custom Auto-Configuration? ⏺️

Declare it in the EnableAutoConfiguration key in the META-INF/spring.factories file.

𝗤𝟴. How to Tell an Auto-Configuration to Back Away When a Bean Exists? 🔙

Use @ConditionalOnMissingBean annotation.

𝗤𝟵. How to Deploy Spring Boot Web Applications as Jar and War Files? 📦

Add a plugin element to pom.xml: spring-boot-maven-plugin and set the packaging: jar.

𝗤𝟭𝟬. How to Use Spring Boot for Command-Line Applications? 🧑‍💻

Launch the main method of the class containing @SpringBootApplication like any classic Java class.

𝗤𝟭𝟭. What Are Possible Sources of External Configuration? 🔧

We can use properties files, YAML files...

𝗤𝟭𝟮. What Does It Mean That Spring Boot Supports Relaxed Binding? 🧘‍♀️

It means a property myProp can be bound to any of these environment properties: myProp, my-prop, my_prop, or MY_PROP.

𝗤𝟭𝟯. What Is Spring Boot DevTools Used For? 🧑‍🔧

Applications using DevTools restart whenever a file on the classpath changes.

𝗤𝟭𝟰. How to Write Integration Tests? 🐛

With @SpringBootTest.

𝗤𝟭𝟱. What Is Spring Boot Actuator Used For? 🧑‍⚕️

It allows us to monitor and manage applications running in production.

𝗤𝟭𝟲. Which Is Better to Configure a Spring Boot Project — Properties or YAML? 💪

YAML

𝗤𝟭𝟳. What Basic Annotations Does Spring Boot Offer? 🎁

@EnableAutoConfiguration, @SpringBootApplication

𝗤𝟭𝟴. How to Change the Default Port in Spring Boot? ⚓

Use a properties file or set server.port in the @SpringBootApplication class or in the command line: java -jar -Dserver.port=8081 myspringproject.jar.

𝗤𝟭𝟵. Which Embedded Servers Does Spring Boot Support, and How to Change the Default? 🖥️

Tomcat, Jetty, and Undertow, change it in the pom.xml.

𝗤𝟮𝟬. Why Do We Need Spring Profiles? 🎭

Spring has the provision of profiles to help separate the configuration for each environment

#spring #java #programming #interviewquestion