Return to site

🍃 Spring Boot Interview Questions

September 17, 2022

ð—Ī𝟭. 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