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