SlideShare uma empresa Scribd logo
1 de 130
Why should you use Spring
Boot?
www.edureka.co
Why should you use Spring Boot?
Stability Based
on JVM
Open
Source
Cloud-
Native
Connectivity Flexibility
www.edureka.co
Java Spring Boot Developer Salary Trend
www.edureka.co
www.edureka.co
Spring Boot
Interview Questions
Whatarethedifferencesbetween
SpringandSpringBoot?
Question 1
www.edureka.co
Question 1
Whatarethedifferencesbetween
SpringandSpringBoot?
Spring SpringBoot
AwebapplicationframeworkbasedonJava AmoduleofSpring
Providestoolsandlibrariestocreate
customizedwebapplications
UsedtocreateaSpringapplicationproject
whichcanjustrun/execute
SpringismorecomplexthanSpringBoot
SpringBootislesscomplexthantheSpring
framework
Takesanunopinionatedview Takesanopinionatedviewofaplatform
Spring Boot
Interview Questions
www.edureka.co
WhatisSpringBootandmention
theneedforit?
Question 2
Spring Boot
Interview Questions
www.edureka.co
Question 2
Usedtocreate stand-alone Spring-based applications
whichyoucanjustrun
Spring Boot isaSpringmodulewhichaimstosimplifytheuseofthe
SpringframeworkforJava development.
Spring Boot
Interview Questions
www.edureka.co
❑ Auto-dependencyResolution
❑ EmbeddedHTTPservers
❑ Auto-configuration
❑ Managementendpoints
❑ SpringBootCLI
WhatisSpringBootandmention
theneedforit?
AimsatRapid Application Development
SpringBootframeworkcomeswith
WhataretheadvantagesofSpring
Boot?
Question 3
Spring Boot
Interview Questions
www.edureka.co
Question 3
Spring Boot
Interview Questions
www.edureka.co
WhataretheadvantagesofSpring
Boot?
Advantages of Spring Boot
01 Provides autoconfiguration to load a set of default configuration for a quick start
of the application
02Creates stand-alone applications with a range of non-functional features that are
common to large classes of project
03 Spring Boot comes with embedded tomcat, servlet containers jetty to avoid the
usage of WAR files
04Spring Boot provides an opinionated view to reduce the developer effort and
simplify maven configurations
Question 3
Spring Boot
Interview Questions
www.edureka.co
WhataretheadvantagesofSpring
Boot?
Advantages of Spring Boot
05 Provides CLI tool to develop and test applications
06Comes with Spring Boot starters to ensure dependency management and also
provides various security metrics
07 Consists of a wide range of APIs for monitoring and managing applications in dev
and prod.
08Integrates with Spring Ecosystem like Spring JDBC, Spring ORM, Spring Data,
Spring Security easily by avoiding boilerplate code.
MentionafewfeaturesofSpring
Boot
Question 4
Spring Boot
Interview Questions
www.edureka.co
Question 4
Spring Boot
Interview Questions
www.edureka.co
MentionafewfeaturesofSpring
Boot
Spring CLISpring CLISpring CLI
SpringBootCLIallowsyou
toGroovyforwritingSpringboot
applicationandavoids
boilerplatecode.
Starter DependencyStarter DependencyStarter Dependency
Withthehelpofthisfeature,
SpringBootaggregatescommon
dependenciestogetherand
eventuallyimprovesproductivity
Spring InitializerSpring InitializerSpring Initializer
Thisisbasicallyaweb
application,whichcan createan
internalprojectstructureforyou.
Auto-configurationAuto-configurationAuto-configuration
Theauto-configurationfeatureof
SpringBoothelpsinloadingthe
defaultconfigurationsaccordingto
theprojectyouareworkingon
Spring ActuatorSpring ActuatorSpring Actuator
Thisfeatureprovideshelpwhile
runningSpringBootapplications.
Logging and SecurityLogging and SecurityLogging and Security
ThisfeatureofSpringBoot,ensures
thatalltheapplicationsmadeusing
SpringBootareproperlysecured
withoutanyhassle.
ExplainhowtocreateSpringBoot
applicationusingMaven
Question 5
Spring Boot
Interview Questions
www.edureka.co
Question 5
Spring Boot
Interview Questions
www.edureka.co
ExplainhowtocreateSpringBoot
applicationusingMaven
TherearevariousapproachestocreateaSpringBootapplication using
maven:
❑Spring Boot CLI
❑Spring Boot Project Wizard
❑Spring Boot Initializer
❑Spring Maven Project
Whatarethethepossiblesources
ofexternalconfiguration?
Question 6
Spring Boot
Interview Questions
www.edureka.co
Question 6
Spring Boot
Interview Questions
www.edureka.co
Whatarethethepossiblesources
ofexternalconfiguration?
Application Properties
Command Line Properties
Profile Specific Properties
MostPossibleSourcesOfExternalConfiguration
Canyouexplainwhathappensin
thebackgroundwhenaSpringBoot
Applicationis“RunasJava
Application”?
Question 7
Spring Boot
Interview Questions
www.edureka.co
Question 7
Spring Boot
Interview Questions
www.edureka.co
Canyouexplainwhathappensin
thebackgroundwhenaSpringBoot
Applicationis“RunasJava
Application”?
WhenaSpring Boot application isexecutedas“Run
as Java application”,thenitautomatically
launches up the tomcat serverassoonasitsees,that
youaredevelopingawebapplication.
WhataretheSpringBootstarters
andwhatareavailablethe
starters?
Question 8
Spring Boot
Interview Questions
www.edureka.co
Question 8
WhataretheSpringBootstarters
andwhatareavailablethe
starters?
Spring Boot
Interview Questions
www.edureka.co
Spring Boot starters areasetofconvenient dependency
managementproviderswhichcanbeusedintheapplicationtoenable
dependencies. Thesestartersmakedevelopmenteasyandrapid.Allthe
availablestarterscomeunderthe
org.springframework.boot group.
Question 8
WhataretheSpringBootstarters
andwhatareavailablethe
starters?
Spring Boot
Interview Questions
www.edureka.co
01 spring-boot-starter
02 spring-boot-starter-jdbc
03 spring-boot-starter-web
04 spring-boot-starter-data-jpa
05 spring-boot-starter-security
06 spring-boot-starter-aop
07 spring-boot-starter-test
Question 9
Spring Boot
Interview Questions
www.edureka.co
ExplainSpringActuatorandits
advantages
Question 9
ExplainSpringActuatorandits
advantages
Spring Boot
Interview Questions
www.edureka.co
Spring Actuator isacoolfeatureofSpring Boot withthe
helpofwhichyoucanseewhatishappeninginsidearunning
application.
TheSpringActuatorprovidesaveryeasywaytoaccesstheproduction-
readyREST points andfetchallkindsofinformationfromtheweb.
ThesepointsaresecuredusingSpring Security’s content
negotiation strategy.
Question 10
Spring Boot
Interview Questions
www.edureka.co
WhatisSpringBootdependency
management?
Question 10
Spring Boot
Interview Questions
www.edureka.co
WhatisSpringBootdependency
management?
Spring Boot dependency management isusedtomanage
dependenciesandconfigurationautomaticallywithoutyouspecifyingthe
versionforanyofthatdependencies.
Question 11
Spring Boot
Interview Questions
www.edureka.co
Mentiontheminimum
requirementsforaSpringboot
System
Question 11
Spring Boot
Interview Questions
www.edureka.co
Mentiontheminimum
requirementsforaSpringboot
System
Spring Boot 2.1.7.Release requires
✓ Java8+
✓ SpringFramework5.1.9+
Explicit Build Support
✓ Maven3.3+
✓ Gradle4.4+
Servlet Container Support
✓ Tomcat9.0–ServletVersion4.0
✓ Jetty9.4– ServletVersion3.1
✓ Undertow2.0–Servlet Version4.0
Question 12
Spring Boot
Interview Questions
www.edureka.co
Whatisthymeleafandhowtouse
thymeleaf?
Question 12
Spring Boot
Interview Questions
www.edureka.co
Thymeleaf is a server-side Java template engine used
forwebapplications.
Itaims to bringnaturaltemplatefor yourwebapplication andcan integrate
well with Spring Framework and HTML5 Java web
applications.
Whatisthymeleafandhowtouse
thymeleaf?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
thymeleaf</artifactId>
</dependency>
Question 13
Spring Boot
Interview Questions
www.edureka.co
Canwechangetheportof
embeddedTomcatserverinSpring
Boot?
Question 13
Spring Boot
Interview Questions
www.edureka.co
Canwechangetheportof
embeddedTomcatserverinSpring
Boot?
Yes,wecanchangetheportoftheembeddedtomcatserverbyusing
theapplication properties file.
Inthisfile,youhavetoaddapropertyof“server.port”andassignitto
anyportyouwishto.
Forexample,ifyouwanttoassignitto8081,thenyouhavetomention
server.port=8081
Onceyoumentiontheportnumber,theapplicationpropertiesfilewill
beautomaticallyloadedbySpringBootandtherequired
configurationswillbeappliedontotheapplication.
Question 14
Spring Boot
Interview Questions
www.edureka.co
WhatistheneedforSpringBoot
DevTools?
Question 14
Spring Boot
Interview Questions
www.edureka.co
Spring Boot Dev Tools isanelaboratedsetoftools
andaimstomaketheprocessofdevelopinganapplicationeasier.
Iftheapplicationrunsintheproduction,thenthismoduleis
automaticallydisabled,repackagingofarchivesarealso
excludedbydefault.
So,theSpring Boot Developer Tools applies
propertiestotherespectivedevelopmentenvironments.
WhatistheneedforSpringBoot
DevTools?
Question 14
Spring Boot
Interview Questions
www.edureka.co
WhatistheneedforSpringBoot
DevTools?
Question 14
Spring Boot
Interview Questions
www.edureka.co
Spring Boot Dev Tools isanelaboratedsetoftoolsandaims
tomaketheprocessofdevelopinganapplicationeasier.
Iftheapplicationrunsintheproduction,thenthismoduleisautomatically
disabled,repackagingofarchivesarealsoexcludedbydefault.
WhatistheneedforSpringBoot
DevTools?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
thymeleaf</artifactId>
</dependency>
Question 15
Spring Boot
Interview Questions
www.edureka.co
Mentionthestepstocreatea
SpringBootprojectusing
Spring Initializer
Question 15
Spring Boot
Interview Questions
www.edureka.co
Spring Initializer isawebtoolprovidedbySpring.Withthe
helpofthistool,youcancreateSpringBootprojectsbyjust
providingprojectdetails.
Mentionthestepstocreatea
SpringBootprojectusing
Spring Initializer
Question 15
Spring Boot
Interview Questions
www.edureka.co
Mentionthestepstocreatea
SpringBootprojectusing
Spring Initializer
✓ Choose the maven project and the required dependencies. Then, fill
the other required details like Group, Artifact, and then click on
GenerateProject.
✓ Once the project is downloaded, extract the project on to your
system
✓ Next, you have to import this project using the import option on the
SpringToolSuiteIDE
Question 16
Spring Boot
Interview Questions
www.edureka.co
Mentionthestepstoconnect
SpringBootapplicationtoa
databaseusingJDBC
Question 16
Spring Boot
Interview Questions
www.edureka.co
SpringBootstarterprojectsprovidetherequiredlibrariesto
connecttheapplicationwithJDBC.
So,forexample,ifyoujusthavetocreateanapplication and
connectitwithMYSQLdatabase,youcanfollowthebelowsteps:
Mentionthestepstoconnect
SpringBootapplicationtoa
databaseusingJDBC
Step 1: Create a database in MySQL
CREATE DATABASE example;
Step 2: Create a table inside this database
CREATE TABLE customers(customerid INT PRIMARY KEY
NOT NULL AUTO_INCREMENT, customername
VARCHAR(255));
Question 16
Spring Boot
Interview Questions
www.edureka.co
Mentionthestepstoconnect
SpringBootapplicationtoa
databaseusingJDBC
Step 3: Create a Spring Boot project and provide
the required details
Step 4: Add JDBC, MySQL and web dependencies.
spring.datasource.url=jdbc:mysql://localhost:3306/e
xample
spring.datasource.username=root
spring.datasource.password=mysql
spring.jpa.hibernate.ddl-auto=create-drop
Step 5: Once the project is created, you have to
configure the database into application
properties.
Question 16
Spring Boot
Interview Questions
www.edureka.co
Mentionthestepstoconnect
SpringBootapplicationtoa
databaseusingJDBC
Step 6: The main application.java class should have
the following code:
package com.edureka;
import org.springframework.boot.SpringApplication;
import
org.springframework.boot.autoconfigure.SpringBootAp
plication;
@SpringBootApplication
public class SampleApplication {
public static void main(String[] args) {
SpringApplication.run(SampleApplication.class,
args);
}
}
Question 16
Spring Boot
Interview Questions
www.edureka.co
Mentionthestepstoconnect
SpringBootapplicationtoa
databaseusingJDBC
Step 7: You have to create a controller to handle
the HTTP requests, by mentioning the following
code:
package com.edureka;
Import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class JdbcController {
@Autowired
JdbcTemplate jdbc;
@RequestMapping("/insert")
public String index(){
jdbc.execute("insert into customers(name)values('Aryya')");
return "Data Entry Successful";
}
}
Question 16
Spring Boot
Interview Questions
www.edureka.co
Mentionthestepstoconnect
SpringBootapplicationtoa
databaseusingJDBC
Step 8: Finally execute this project as a Java
application.
Step 9: Open the URL (localhost:8080/insert), and you
will see the output as data entry successful.
You can also go forward and check if the data is
entered into the table.
Question 17
Spring Boot
Interview Questions
www.edureka.co
HowtoenableHTTP/2supportin
SpringBoot
Question 17
Spring Boot
Interview Questions
www.edureka.co
HowtoenableHTTP/2supportin
SpringBoot
YoucanenabletheHTTP/2supportinSpringBootby:
server.http2.enabled=true
Question 18
Spring Boot
Interview Questions
www.edureka.co
Whatarethe
@RequestMapping and
@RestControllerannotationin
SpringBootusedfor?
Question 18
Spring Boot
Interview Questions
www.edureka.co
Whatarethe
@RequestMapping and
@RestControllerannotationin
SpringBootusedfor?
✓ Thisannotationisusedtoprovidetheroutinginformationandtellsto
SpringthatanyHTTPrequestmustbemappedtotherespective
method.
✓ Tousethisannotation,youhavetoimport
org.springframework.web.bind.annotation.RequestMapping;
@RequestMapping@RequestMapping
✓ Thisannotationisusedtoprovidetheroutinginformationandtellsto
SpringthatanyHTTPrequestmustbemappedtotherespective
method.
✓ Tousethisannotation, youhavetoimport
org.springframework.web.bind.annotation.RequestMapping;
@RestController@RestController
Question 18
Spring Boot
Interview Questions
www.edureka.co
Whatarethe
@RequestMapping and
@RestControllerannotationin
SpringBootusedfor?
package com.edureka;
import
org.springframework.web.bind.annotation.RequestMapp
ing;
import
org.springframework.web.bind.annotation.RestControl
ler;
@RestController
public class SampleController {
@RequestMapping("/example")
public String example(){
return"Welcome To Edureka";
}
}
Consideryouhaveamethodexample()whichshouldmapwith/exampleURL.
Question 19
Spring Boot
Interview Questions
www.edureka.co
WhatisSpringBootCLIandhowto
executetheSpringBootproject
usingbootCLI?
Question 19
Spring Boot
Interview Questions
www.edureka.co
SpringBootCLIisatoolsupportedbytheofficial SpringFramework.The
stepstoexecuteaSpringBootprojectareasfollows:
➢ DownloadtheCLItoolfromtheofficialsiteandextractthezipfile.The
binfolderpresentintheSpringsetupisusedtoexecutetheSpring
Bootapplication.
➢ SinceSpringBootCLIexecutesgroovyfiles,youneedtocreatea
groovyfileforSpringBootapplication.So,todothat,openterminaland
changethecurrentdirectorytobinfolder.
WhatisSpringBootCLIandhowto
executetheSpringBootproject
usingbootCLI?
Question 19
Spring Boot
Interview Questions
www.edureka.co
Createacontrollerasfollows:
WhatisSpringBootCLIandhowto
executetheSpringBootproject
usingbootCLI?
@RestController public class Sample {
@RequestMapping("/example")
String index(){
<h1>"Welcome To Edureka"</h1>;
} }
Executethegroovyfilebymentioning
./spring run Sample.groovy;
Question 20
Spring Boot
Interview Questions
www.edureka.co
Whatarethedifferencesbetween
JPAandHibernate?
Question 20
Spring Boot
Interview Questions
www.edureka.co
Whatarethedifferencesbetween
JPAandHibernate?
JPAisaDataAccessAbstractionusedtoreducetheamountofboilerplate
code
JPAJPA
HibernateisanimplementationofJavaPersistenceAPIandoffers
benefitsofloosecoupling
HibernateHibernate
V/S
Howcanwecreateacustom
endpointinSpringBootActuator?
Question 21
Spring Boot
Interview Questions
www.edureka.co
Question 21
Spring Boot
Interview Questions
www.edureka.co
TocreateacustomendpointinSpringBoot2.x,youcanusethe
@Endpoint annotation.
SpringBootalsoexposesendpointsusing@WebEndpointor,
@WebEndpointExtensionoverHTTPwiththehelp
ofSpringMVC,Jerseyetc.
Howcanwecreateacustom
endpointinSpringBootActuator?
WhatdoyouunderstandbySpring
Data?
Question 22
Spring Boot
Interview Questions
www.edureka.co
Question 22
Spring Boot
Interview Questions
www.edureka.co
Spring Data aimstomakeiteasyforthedeveloperstouse
relationalandnon-relationaldatabases,cloud-baseddataservices,
andotherdataaccesstechnologies.
So,basically,itmakesiteasyfordataaccessandstillretainsthe
underlyingdata.
WhatdoyouunderstandbySpring
Data?
Whatdoyouunderstandbyauto-
configurationinSpringBootand
howtodisablethe auto-
configuration
Question 23
Spring Boot
Interview Questions
www.edureka.co
Question 23
Spring Boot
Interview Questions
www.edureka.co
Auto-configuration isusedtoautomaticallyconfigurethe
requiredconfigurationfortheapplication.
Forexample,ifyouhaveadatasourcebeanpresentintheclasspathof
theapplication,thenitautomaticallyconfigurestheJDBCtemplate.
Withthehelpofauto-configuration,youcancreateaJavaapplication
inaneasyway,asitautomaticallyconfigurestherequiredbeans,
controllers,etc.
Whatdoyouunderstandbyauto-
configurationinSpringBootand
howtodisablethe auto-
configuration
Question 23
Spring Boot
Interview Questions
www.edureka.co
Todisabletheauto-configuration property,youhaveto
excludeattributeof @EnableAutoConfiguration,inthe
scenariowhereyoudonotwantittobeapplied.
Whatdoyouunderstandbyauto-
configurationinSpringBootand
howtodisablethe auto-
configuration
@EnableAutoConfiguration(exclude={DataSourceAutoConfig
uration.class})
Iftheclassisnotontheclasspath,thentoexcludetheauto-
configuration,youhavetomentionthefollowingcode:
@EnableAutoConfiguration(excludeName={Sample.class})
Question 23
Spring Boot
Interview Questions
www.edureka.co
Whatdoyouunderstandbyauto-
configurationinSpringBootand
howtodisablethe auto-
configuration
Apartfromthis,SpringBootalsoprovidesthefacilitytoexcludelistof
auto-configurationclassesbyusingthespring.autoconfigure.exclude
property.Youcangoforward,andadditeitherintothe
application.properties oraddmultipleclasseswithcomma-separated.
Whatarethedifferencesbetween
@SpringBootApplication and
@EnableAutoConfiguration
annotation?
Question 24
Spring Boot
Interview Questions
www.edureka.co
Question 24
Spring Boot
Interview Questions
www.edureka.co
Whatarethedifferencesbetween
@SpringBootApplication and
@EnableAutoConfiguration
annotation?
✓ Usedinthemainclassorbootstrapclass
✓ Itisacombinationof@Configuration,@ComponentScan and
@EnableAutoConfiguration annotations.
@SpringBootApplication@SpringBootApplication
✓ Usedtoenableauto-configuration andcomponentscanninginyour
project
✓ Itisacombinationof@Configurationand@ComponentScan
annotations
@EnableAutoConfiguration@EnableAutoConfiguration
V/S
WhatarethestepstodeploySpring
BootwebapplicationsasJARand
WARfiles?
Question 25
Spring Boot
Interview Questions
www.edureka.co
Question 25
Spring Boot
Interview Questions
www.edureka.co
✓ TodeployaSpringBootwebapplication,youjusthavetoaddthe
followingplugininthepom.xmlfilein,justaddapluginelement
topom.xml:
@SpringBootApplication@SpringBootApplication
WhatarethestepstodeploySpring
BootwebapplicationsasJARand
WARfiles?
@<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
Question 25
Spring Boot
Interview Questions
www.edureka.co
✓ Thepackagingelementinthepom.xmlfilemustbesettojartobuilda
JARfileasbelow:
@SpringBootApplication@SpringBootApplication
WhatarethestepstodeploySpring
BootwebapplicationsasJARand
WARfiles?
<packaging>jar</packaging>
<packaging>war</packaging>
Canyougiveanexamplefor
ReadOnlyastrueinTransaction
management?
Question 26
Spring Boot
Interview Questions
www.edureka.co
Question 26
Spring Boot
Interview Questions
www.edureka.co
Considerascenario,whereyouhavetoreaddatafromthedatabase.
Forexample,letussayyouhaveacustomerdatabase,andyouwantto
readthecustomerdetailssuchascustomerID,customername,and
customeremailID.
Todothat,youwillsetread-onlyonthetransactionaswedonotwantto
checkforthechangesintheentities.
Canyougiveanexamplefor
ReadOnlyastrueinTransaction
management?
Canyouexplainhowtodeploytoa
different serverwithSpringBoot?
Question 27
Spring Boot
Interview Questions
www.edureka.co
Spring Boot
Interview Questions
www.edureka.co
TodeployadifferentserverwithSpringBoot,followthebelowsteps:
Canyouexplainhowtodeploytoa
different serverwithSpringBoot?
Question 27
01 GenerateaWARfromtheproject
02 DeploytheWARfileontoyourfavouriteserver
Question 27
Whatisthebestwaytoexpose
customapplicationconfiguration
withSpringBoot?
Question 28
Spring Boot
Interview Questions
www.edureka.co
Spring Boot
Interview Questions
www.edureka.co
OnewaytoexposethecustomapplicationconfigurationinSpringBootis
byusingthe@Value annotation.
But,theonlyproblemwiththisannotationisthatalltheconfiguration
valueswillbedistributedthroughouttheapplication.
Instead,youcanuseacentralized approach.
Bycentralizedapproach,Imeanthatyoucandefineaconfiguration
componentusingthe@ConfigurationProperties asfollows:
Question 28
Whatisthebestwaytoexpose
customapplicationconfiguration
withSpringBoot?
<packaging>@Component
@ConfigurationProperties("example")
public class SampleConfiguration {
private int num;
private boolean value;
private String msg;</packaging>
Spring Boot
Interview Questions
www.edureka.co
Accordingtotheabovesnippet,thevaluesconfiguredin
application.properties willbeasfollows:
Question 28
Whatisthebestwaytoexpose
customapplicationconfiguration
withSpringBoot?
example.num: 100
example.value: true
example.msg: Dynamic Message
Canwecreateanon-web
applicationinSpringBoot?
Question 29
Spring Boot
Interview Questions
www.edureka.co
Spring Boot
Interview Questions
www.edureka.co
Question 29
Canwecreateanon-web
applicationinSpringBoot?
Yes,wecancreate a non-web applicationbyremovingthe
webdependenciesfromclasspathalongwithchangingthewaySpring
Boot creates the application context.
Whatarethestepstoconnectan
externaldatabaselikeMySQLor
Oracle?
Question 30
Spring Boot
Interview Questions
www.edureka.co
Spring Boot
Interview Questions
www.edureka.co
Question 30
Toconnectanexternaldatabase,youhavetofollowthebelowsteps:
➢ StartbyaddingthedependencyforMySQLConnectortopom.xml
➢ ThenremoveH2Dependencyfrompom.xml
➢ Now,setupyourMySQLdatabaseandconfigureyourconnectiontothe
MySQLdatabase
➢ Restartyourproject
Whatarethestepstoconnectan
externaldatabaselikeMySQLor
Oracle?
MentiontheadvantagesofYAML
filethanPropertiesfileandthe
different waystoloadYAMLfilein
Springboot
Question 31
Spring Boot
Interview Questions
www.edureka.co
Spring Boot
Interview Questions
www.edureka.co
Question 31 TheadvantagesoftheYAMLfilethanapropertiesfileisthatthedatais
storedinahierarchicalformat.
So,itbecomesveryeasyforthedeveloperstodebugifthereisanissue.
TheSpringApplicationclasssupportstheYAMLfileasanalternative to
propertieswheneveryouusetheSnakeYAMLlibraryonyourclasspath.
The different ways to load a YAML file in Spring
Boot is as follows:
➢ UseYamlMapFactoryBeantoloadYAMLasaMap
➢ UseYamlPropertiesFactoryBean toloadYAMLasProperties
MentiontheadvantagesofYAML
filethanPropertiesfileandthe
different waystoloadYAMLfilein
Springboot
HowisHibernatechosenasthe
defaultimplementationforJPA
withoutanyconfiguration?
Question 32
Spring Boot
Interview Questions
www.edureka.co
Spring Boot
Interview Questions
www.edureka.co
Question 32
WhenweusetheSpring Boot Auto Configuration,
automaticallythespring-boot-starter-data-
jpadependencygetsaddedtothepom.xmlfile.
Now,sincethisdependencyhasatransitivedependencyonJPAand
Hibernate,Spring Boot automatically auto-
configures Hibernate as the default
implementation for JPA,wheneveritseesHibernatein
theclasspath.
HowisHibernatechosenasthe
defaultimplementationforJPA
withoutanyconfiguration?
WhatdoyouunderstandbySpring
DataREST?
Question 33
Spring Boot
Interview Questions
www.edureka.co
Spring Boot
Interview Questions
www.edureka.co
Question 33
Spring Data REST isusedtoexposetheRESTfulresources
aroundSpringDatarepositories.
Considerthefollowingexample:
WhatdoyouunderstandbySpring
DataREST?
@RepositoryRestResource(collectionResourceRel =
"sample", path = "sample")
public interface SampleRepository
extends CustomerRepository<sample, Long> {
Spring Boot
Interview Questions
www.edureka.co
Question 33
WhatdoyouunderstandbySpring
DataREST?
ToexposetheRESTservices,youcanusethePOSTmethodinthe
followingway:
{
"customerid": "Rohit",
"customeremailid": "customer1@abc.com"
}
ResponseContent:
{
"customerid": "Rohit",
"customeremailid": "customer1@abc.com",
"_links": {
"self": {
"href": "http://localhost:8080/sample/1"
},
"sample": {
"href": "http://localhost:8080/sample/1"
}}
Whatisthedifferencebetween
RequestMappingandGetMapping?
Question 34
Spring Boot
Interview Questions
www.edureka.co
Spring Boot
Interview Questions
www.edureka.co
Question 34
The@GetMappingisacomposedannotationthatactsasashortcut
for@RequestMapping(method =RequestMethod.GET).
Boththesemethodssupporttheconsumes.Theconsumeoptionsare:
consumes=“text/plain”
consumes={“text/plain”,“application/*”}
Whatisthedifferencebetween
RequestMappingandGetMapping?
Inwhichlayer,shouldtheboundary
ofatransactionstart?
Question 35
Spring Boot
Interview Questions
www.edureka.co
Spring Boot
Interview Questions
www.edureka.co
Question 35
Theboundary of the transaction shouldstartfromthe
ServiceLayersincethelogicforthebusinesstransactionispresentin
thislayeritself.
Inwhichlayer,shouldtheboundary
ofatransactionstart?
Howdoespath=”sample”,
collectionResourceRel=”sample”
workwithSpringDataRest?
Question 36
Spring Boot
Interview Questions
www.edureka.co
Spring Boot
Interview Questions
www.edureka.co
Question 36
Howdoespath=”sample”,
collectionResourceRel=”sample”
workwithSpringDataRest?
@RepositoryRestResource(collectionResourceRel =
"sample", path = "sample")
public interface SampleRepository extends
PagingAndSortingRepository<Sample, Long>
➢ path – This section is used to mention the segment under
whichtheresourceistobeexported.
➢ collectionResourceRel – This value is used to
generatelinkstothecollectionresource.
Question 37
Spring Boot
Interview Questions
www.edureka.co
Explainhowtoregisteracustom
auto-configuration.
Spring Boot
Interview Questions
www.edureka.co
Question 37
Explainhowtoregisteracustom
auto-configuration.
Inordertoregisteranauto-configurationclass,youhavetomention
the fully-qualified name underthe
@EnableAutoConfiguration key META-
INF/spring. factories file.
Also,ifwebuildthewithmaven,thenthisfileshouldbeplacedinthe
resources/META-INT directory.
Question 38
Spring Boot
Interview Questions
www.edureka.co
HowdoyouConfigureLog4jfor
logging?
Spring Boot
Interview Questions
www.edureka.co
Question 38
SinceSpringBootsupports Log4j2 for logging a
configuration,youhavetoexclude Logback and
include Log4j2 for logging.Thiscanbeonlydoneifyouare
usingthestartersproject.
HowdoyouConfigureLog4jfor
logging?
Question 39
Spring Boot
Interview Questions
www.edureka.co
Mentionthedifferencesbetween
WARandembeddedcontainers
Spring Boot
Interview Questions
www.edureka.co
Question 39
HowdoyouConfigureLog4jfor
logging?
WARbenefitsaconsiderablemeasurefromSpringBoot
WARWAR
OnlyonecomponentofSpringBootandisutilizedduringimprovements
EmbeddedContainersEmbeddedContainers
V/S
Question 40
Spring Boot
Interview Questions
www.edureka.co
Whatdoyouthinkistheneedfor
Profiles?
Spring Boot
Interview Questions
www.edureka.co
Question 40
ProfilesinSpringprovidesawaytosegregatethepartsofthe
applicationconfigurationandmakesitavailableinenvironments.So,
basically,any@Component or a @Configuration can
bemarkedwitha@Profiletolimitasitisloaded.
Whatdoyouthinkistheneedfor
Profiles?
Question 41
Spring Boot
Interview Questions
www.edureka.co
Whatdoyouthinkistheneedfor
Profiles?
Spring Boot
Interview Questions
www.edureka.co
Question 41 ThestepstoaddacustomJScodewithSpringBootareas
follows:
✓ Createafoldercalledstaticundertheresourcesfolder
✓ Inthisfolder,youcanputthestaticcontentinthatfolder
Whatarethestepstoaddacustom
JScodewithSpringBoot?
Note:Justincase,thebrowserthrowsanunauthorizederror,youeither
disablethesecurityorsearchforthepasswordinthelogfile,andeventually
passitintherequestheader.
Question 42
Spring Boot
Interview Questions
www.edureka.co
Howtoinstructanauto-
configurationtobackoffwhena
beanexists?
Spring Boot
Interview Questions
www.edureka.co
Question 42
Toinstructanauto-configuration classtobackoffwhenabean
exists,youhavetousethe
@ConditionalOnMissingBean annotation.
Theattributesofthisannotationareasfollows:
➢ value:Thisattributestoresthetypeofbeanstobechecked
➢ name:Thisattributestoresthenameofbeanstobechecked
Howtoinstructanauto-
configurationtobackoffwhena
beanexists?
Question 43
Spring Boot
Interview Questions
www.edureka.co
WhyisSpringDataRESTnot
recommendedinreal-world
applications?
Spring Boot
Interview Questions
www.edureka.co
Question 43 Spring Data REST isnotrecommendedinreal-world
applicationsasyouareexposingyourdatabaseentities directly
asRESTservices.
WhiledesigningRESTfulservices,thetwomostimportantthingsthat
weconsideristhedomainmodelandtheconsumers.
But,whileusingSpringDataREST,noneoftheseparametersare
considered.Theentitiesaredirectlyexposed.
UseSpringDataREST,for the initial evolution of the
project.
WhyisSpringDataRESTnot
recommendedinreal-world
applications?
Question 44
Spring Boot
Interview Questions
www.edureka.co
Whatistheerroryouseeif H2is
notintheclasspath?
Spring Boot
Interview Questions
www.edureka.co
Question 44
IfH2isnotpresentintheclasspath,thenyouseethefollowing
error:
Whatistheerroryouseeif H2is
notintheclasspath?
Cannot determine embedded database driver class for
database type NONE
Spring Boot
Interview Questions
www.edureka.co
Question 44
Whatistheerroryouseeif H2is
notintheclasspath?
Toresolvethiserror,addH2tothepom.xmlfile,andrestartyour
server.
Thefollowingcodesnippetcanbeaddedtoaddthedependency:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
Question 45
Spring Boot
Interview Questions
www.edureka.co
Whatisthewaytouseprofilesto
configuretheenvironment-
specificconfigurationwithSpring
Boot?
Spring Boot
Interview Questions
www.edureka.co
Question 45
Whatisthewaytouseprofilesto
configuretheenvironment-
specificconfigurationwithSpring
Boot?
Since its a known fact that a Profile is nothing but a key to identify
an environment lets consider the following two profiles in the
example:
•dev
•Prod
Consider the following properties present in the application
propertiesfile:
example.number: 100
example.value: true
example.msg: Dynamic Message
Spring Boot
Interview Questions
www.edureka.co
Question 45
Whatisthewaytouseprofilesto
configuretheenvironment-
specificconfigurationwithSpring
Boot?
Now, say you want to customize the application.properties for dev
profile, then you need to create a file with name application-
dev.properties and override the properties that you want to
customize.
Youcanmentionthefollowingcode:
example.msg: Dynamic Message in Dev
Similarly,ifyouwanttocustomizetheapplication.properties forprod
profile,thenyoucanmentionthefollowingcodesnippet:
example.msg: Dynamic Message in Prod
Spring Boot
Interview Questions
www.edureka.co
Question 45
Whatisthewaytouseprofilesto
configuretheenvironment-
specificconfigurationwithSpring
Boot?
Once you are done with the profile-specific configuration, you
havetosettheactive profileinanenvironment.
Todothat, either youcan:
✓ Use-Dspring.profiles.active=prod in arguments
✓ Usespring.profiles.active=prodinapplication.propertiesfile
Question 46
Spring Boot
Interview Questions
www.edureka.co
Mentionthedependenciesneeded
tostartupaJPAApplicationand
connecttoin-memorydatabaseH2
withSpringBoot?
Spring Boot
Interview Questions
www.edureka.co
Question 46
Mentionthedependenciesneeded
tostartupaJPAApplicationand
connecttoin-memorydatabaseH2
withSpringBoot?
web starter
H2
data JPA starter
ThedependenciesareneededtostartupaJPAApplicationandconnect
toin-memorydatabaseH2withSpringBoot
Spring Boot
Interview Questions
www.edureka.co
Question 46
Mentionthedependenciesneeded
tostartupaJPAApplicationand
connecttoin-memorydatabaseH2
withSpringBoot?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-
jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
Question 47
Spring Boot
Interview Questions
www.edureka.co
WhatdoyouunderstandbySpring
Bootsupportsrelaxedbinding?
Spring Boot
Interview Questions
www.edureka.co
Question 47
WhatdoyouunderstandbySpring
Bootsupportsrelaxedbinding?
Relaxed binding,isawayinwhich,thepropertynamedoesnot
needtomatchthekeyoftheenvironmentproperty.
InSpringBoot,relaxedbindingisapplicabletothetype-safebindingof
theconfigurationproperties.
Spring Boot
Interview Questions
www.edureka.co
Question 47
WhatdoyouunderstandbySpring
Bootsupportsrelaxedbinding?
Forexample,ifapropertyinabeanclasswiththe
@ConfigurationProperties annotationisused
sampleProp,thenitcanbeboundedtoanyofthefollowingenvironment
properties:
❑sampleProp
❑sample_Prop
❑sample_Prop
❑SAMPLE_PROP
Question 48
Spring Boot
Interview Questions
www.edureka.co
Whereisthedatabaseconnection
informationspecifiedandhowdoes
itautomaticallyconnecttoH2?
Spring Boot
Interview Questions
www.edureka.co
Question 48
Whereisthedatabaseconnection
informationspecifiedandhowdoes
itautomaticallyconnecttoH2?
ItisbecauseoftheSpring Boot Autoconfiguration
that,configuresthedependenciesoftheapplication.
So,thedatabaseconnection information,andautomaticallyconnecting
thedatabasetoH2isdonebytheauto-configurationproperty.
Question 49
Spring Boot
Interview Questions
www.edureka.co
WhatisthenameofthedefaultH2
databaseconfiguredbySpring
Boot?
Spring Boot
Interview Questions
www.edureka.co
Question 49
WhatisthenameofthedefaultH2
databaseconfiguredbySpring
Boot?
ThenameofthedefaultH2databaseistestdb
spring.datasource.name=testdb # Name of the
datasource.
Note:Justin-caseifyouareusingH2in-memorydatabase,thenexactly
thatisthenameofSpringBootwhichisusedtosetupyourH2database.
Question 50
Spring Boot
Interview Questions
www.edureka.co
Doyouthink,youcanusejetty
insteadoftomcatinspring-boot-
starter-web?
Spring Boot
Interview Questions
www.edureka.co
Question 50
Yes,wecanusejettyinsteadoftomcatinspring-boot-starter-web,by
removingtheexistingdependencyandincludingthefollowing:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
jetty</artifactId>
</dependency>
Doyouthink,youcanusejetty
insteadoftomcatinspring-boot-
starter-web?
www.edureka.co

Mais conteúdo relacionado

Mais procurados

Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot IntroductionJeevesh Pandey
 
Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...
Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...
Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...Edureka!
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudEberhard Wolff
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to MavenVadym Lotar
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKJosé Paumard
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!Jakub Kubrynski
 
Microservices with Spring Boot Tutorial | Edureka
Microservices with Spring Boot Tutorial | EdurekaMicroservices with Spring Boot Tutorial | Edureka
Microservices with Spring Boot Tutorial | EdurekaEdureka!
 
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...Edureka!
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with SpringJoshua Long
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - CoreDzmitry Naskou
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework tola99
 

Mais procurados (20)

Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Spring Core
Spring CoreSpring Core
Spring Core
 
Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...
Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...
Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!
 
Spring jdbc
Spring jdbcSpring jdbc
Spring jdbc
 
Microservices with Spring Boot Tutorial | Edureka
Microservices with Spring Boot Tutorial | EdurekaMicroservices with Spring Boot Tutorial | Edureka
Microservices with Spring Boot Tutorial | Edureka
 
Spring boot
Spring bootSpring boot
Spring boot
 
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
What Is Spring Framework In Java | Spring Framework Tutorial For Beginners Wi...
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Xke spring boot
Xke spring bootXke spring boot
Xke spring boot
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 

Semelhante a Spring Boot Interview Questions | Edureka

Spring boot vs spring framework razor sharp web applications
Spring boot vs spring framework razor sharp web applicationsSpring boot vs spring framework razor sharp web applications
Spring boot vs spring framework razor sharp web applicationsKaty Slemon
 
Learn Java Programming Language In Gurgaon.pptx
Learn Java Programming Language In Gurgaon.pptxLearn Java Programming Language In Gurgaon.pptx
Learn Java Programming Language In Gurgaon.pptxAPTRON Gurgaon
 
Springboot introduction
Springboot introductionSpringboot introduction
Springboot introductionSagar Verma
 
Module 6 _ Spring Boot for java application to begin
Module 6 _ Spring Boot for java application to beginModule 6 _ Spring Boot for java application to begin
Module 6 _ Spring Boot for java application to beginDeepakprasad838637
 
Java Course for Beginners at Texceed
Java Course for Beginners at TexceedJava Course for Beginners at Texceed
Java Course for Beginners at TexceedSamidha Takle
 
What is Java and its example
What is Java and its exampleWhat is Java and its example
What is Java and its exampleamit kumar
 
7 Common Java Coding Interview Questions With Answers
7 Common Java Coding Interview Questions With Answers7 Common Java Coding Interview Questions With Answers
7 Common Java Coding Interview Questions With AnswersJAMESJOHN130
 
Spring boot.pptx
Spring boot.pptxSpring boot.pptx
Spring boot.pptxKartikSang2
 
Spring Roo and the Cloud (Tutorial) [5th IndicThreads.com Conference On Java,...
Spring Roo and the Cloud (Tutorial) [5th IndicThreads.com Conference On Java,...Spring Roo and the Cloud (Tutorial) [5th IndicThreads.com Conference On Java,...
Spring Roo and the Cloud (Tutorial) [5th IndicThreads.com Conference On Java,...IndicThreads
 
SPring boot.pptx
SPring boot.pptxSPring boot.pptx
SPring boot.pptxKartikSang2
 
Present Market Trend for Java Developer
Present Market Trend for Java DeveloperPresent Market Trend for Java Developer
Present Market Trend for Java DeveloperGyanguide1
 
What all things to consider for a good career in java
What all things to consider for a good career in javaWhat all things to consider for a good career in java
What all things to consider for a good career in javaJanBask Training
 
Spring Book – Chapter 1 – Introduction
Spring Book – Chapter 1 – IntroductionSpring Book – Chapter 1 – Introduction
Spring Book – Chapter 1 – IntroductionTomcy John
 
Overview of Java
Overview of JavaOverview of Java
Overview of Javajosemachoco
 

Semelhante a Spring Boot Interview Questions | Edureka (20)

Spring boot vs spring framework razor sharp web applications
Spring boot vs spring framework razor sharp web applicationsSpring boot vs spring framework razor sharp web applications
Spring boot vs spring framework razor sharp web applications
 
Learn Java Programming Language In Gurgaon.pptx
Learn Java Programming Language In Gurgaon.pptxLearn Java Programming Language In Gurgaon.pptx
Learn Java Programming Language In Gurgaon.pptx
 
Springboot introduction
Springboot introductionSpringboot introduction
Springboot introduction
 
Module 6 _ Spring Boot for java application to begin
Module 6 _ Spring Boot for java application to beginModule 6 _ Spring Boot for java application to begin
Module 6 _ Spring Boot for java application to begin
 
Spring boot competitive tests
Spring boot competitive testsSpring boot competitive tests
Spring boot competitive tests
 
Spring boot competitive tests
Spring boot competitive testsSpring boot competitive tests
Spring boot competitive tests
 
Java Course for Beginners at Texceed
Java Course for Beginners at TexceedJava Course for Beginners at Texceed
Java Course for Beginners at Texceed
 
What is Java and its example
What is Java and its exampleWhat is Java and its example
What is Java and its example
 
7 Common Java Coding Interview Questions With Answers
7 Common Java Coding Interview Questions With Answers7 Common Java Coding Interview Questions With Answers
7 Common Java Coding Interview Questions With Answers
 
Spring boot.pptx
Spring boot.pptxSpring boot.pptx
Spring boot.pptx
 
Spring Roo and the Cloud (Tutorial) [5th IndicThreads.com Conference On Java,...
Spring Roo and the Cloud (Tutorial) [5th IndicThreads.com Conference On Java,...Spring Roo and the Cloud (Tutorial) [5th IndicThreads.com Conference On Java,...
Spring Roo and the Cloud (Tutorial) [5th IndicThreads.com Conference On Java,...
 
SPring boot.pptx
SPring boot.pptxSPring boot.pptx
SPring boot.pptx
 
Present Market Trend for Java Developer
Present Market Trend for Java DeveloperPresent Market Trend for Java Developer
Present Market Trend for Java Developer
 
What all things to consider for a good career in java
What all things to consider for a good career in javaWhat all things to consider for a good career in java
What all things to consider for a good career in java
 
Java articles
Java articlesJava articles
Java articles
 
Spring Framework Training From myTectra in Bangalore
Spring Framework Training From myTectra in BangaloreSpring Framework Training From myTectra in Bangalore
Spring Framework Training From myTectra in Bangalore
 
Spring competitive tests
Spring competitive testsSpring competitive tests
Spring competitive tests
 
Spring Book – Chapter 1 – Introduction
Spring Book – Chapter 1 – IntroductionSpring Book – Chapter 1 – Introduction
Spring Book – Chapter 1 – Introduction
 
Jvm
JvmJvm
Jvm
 
Overview of Java
Overview of JavaOverview of Java
Overview of Java
 

Mais de Edureka!

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaEdureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaEdureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaEdureka!
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaEdureka!
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaEdureka!
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaEdureka!
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaEdureka!
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaEdureka!
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaEdureka!
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaEdureka!
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | EdurekaEdureka!
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEdureka!
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEdureka!
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaEdureka!
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaEdureka!
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaEdureka!
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaEdureka!
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaEdureka!
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | EdurekaEdureka!
 

Mais de Edureka! (20)

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
 

Último

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 

Spring Boot Interview Questions | Edureka

  • 1.
  • 2. Why should you use Spring Boot? www.edureka.co
  • 3. Why should you use Spring Boot? Stability Based on JVM Open Source Cloud- Native Connectivity Flexibility www.edureka.co
  • 4. Java Spring Boot Developer Salary Trend www.edureka.co
  • 7. Question 1 Whatarethedifferencesbetween SpringandSpringBoot? Spring SpringBoot AwebapplicationframeworkbasedonJava AmoduleofSpring Providestoolsandlibrariestocreate customizedwebapplications UsedtocreateaSpringapplicationproject whichcanjustrun/execute SpringismorecomplexthanSpringBoot SpringBootislesscomplexthantheSpring framework Takesanunopinionatedview Takesanopinionatedviewofaplatform Spring Boot Interview Questions www.edureka.co
  • 9. Question 2 Usedtocreate stand-alone Spring-based applications whichyoucanjustrun Spring Boot isaSpringmodulewhichaimstosimplifytheuseofthe SpringframeworkforJava development. Spring Boot Interview Questions www.edureka.co ❑ Auto-dependencyResolution ❑ EmbeddedHTTPservers ❑ Auto-configuration ❑ Managementendpoints ❑ SpringBootCLI WhatisSpringBootandmention theneedforit? AimsatRapid Application Development SpringBootframeworkcomeswith
  • 11. Question 3 Spring Boot Interview Questions www.edureka.co WhataretheadvantagesofSpring Boot? Advantages of Spring Boot 01 Provides autoconfiguration to load a set of default configuration for a quick start of the application 02Creates stand-alone applications with a range of non-functional features that are common to large classes of project 03 Spring Boot comes with embedded tomcat, servlet containers jetty to avoid the usage of WAR files 04Spring Boot provides an opinionated view to reduce the developer effort and simplify maven configurations
  • 12. Question 3 Spring Boot Interview Questions www.edureka.co WhataretheadvantagesofSpring Boot? Advantages of Spring Boot 05 Provides CLI tool to develop and test applications 06Comes with Spring Boot starters to ensure dependency management and also provides various security metrics 07 Consists of a wide range of APIs for monitoring and managing applications in dev and prod. 08Integrates with Spring Ecosystem like Spring JDBC, Spring ORM, Spring Data, Spring Security easily by avoiding boilerplate code.
  • 14. Question 4 Spring Boot Interview Questions www.edureka.co MentionafewfeaturesofSpring Boot Spring CLISpring CLISpring CLI SpringBootCLIallowsyou toGroovyforwritingSpringboot applicationandavoids boilerplatecode. Starter DependencyStarter DependencyStarter Dependency Withthehelpofthisfeature, SpringBootaggregatescommon dependenciestogetherand eventuallyimprovesproductivity Spring InitializerSpring InitializerSpring Initializer Thisisbasicallyaweb application,whichcan createan internalprojectstructureforyou. Auto-configurationAuto-configurationAuto-configuration Theauto-configurationfeatureof SpringBoothelpsinloadingthe defaultconfigurationsaccordingto theprojectyouareworkingon Spring ActuatorSpring ActuatorSpring Actuator Thisfeatureprovideshelpwhile runningSpringBootapplications. Logging and SecurityLogging and SecurityLogging and Security ThisfeatureofSpringBoot,ensures thatalltheapplicationsmadeusing SpringBootareproperlysecured withoutanyhassle.
  • 16. Question 5 Spring Boot Interview Questions www.edureka.co ExplainhowtocreateSpringBoot applicationusingMaven TherearevariousapproachestocreateaSpringBootapplication using maven: ❑Spring Boot CLI ❑Spring Boot Project Wizard ❑Spring Boot Initializer ❑Spring Maven Project
  • 18. Question 6 Spring Boot Interview Questions www.edureka.co Whatarethethepossiblesources ofexternalconfiguration? Application Properties Command Line Properties Profile Specific Properties MostPossibleSourcesOfExternalConfiguration
  • 20. Question 7 Spring Boot Interview Questions www.edureka.co Canyouexplainwhathappensin thebackgroundwhenaSpringBoot Applicationis“RunasJava Application”? WhenaSpring Boot application isexecutedas“Run as Java application”,thenitautomatically launches up the tomcat serverassoonasitsees,that youaredevelopingawebapplication.
  • 22. Question 8 WhataretheSpringBootstarters andwhatareavailablethe starters? Spring Boot Interview Questions www.edureka.co Spring Boot starters areasetofconvenient dependency managementproviderswhichcanbeusedintheapplicationtoenable dependencies. Thesestartersmakedevelopmenteasyandrapid.Allthe availablestarterscomeunderthe org.springframework.boot group.
  • 23. Question 8 WhataretheSpringBootstarters andwhatareavailablethe starters? Spring Boot Interview Questions www.edureka.co 01 spring-boot-starter 02 spring-boot-starter-jdbc 03 spring-boot-starter-web 04 spring-boot-starter-data-jpa 05 spring-boot-starter-security 06 spring-boot-starter-aop 07 spring-boot-starter-test
  • 24. Question 9 Spring Boot Interview Questions www.edureka.co ExplainSpringActuatorandits advantages
  • 25. Question 9 ExplainSpringActuatorandits advantages Spring Boot Interview Questions www.edureka.co Spring Actuator isacoolfeatureofSpring Boot withthe helpofwhichyoucanseewhatishappeninginsidearunning application. TheSpringActuatorprovidesaveryeasywaytoaccesstheproduction- readyREST points andfetchallkindsofinformationfromtheweb. ThesepointsaresecuredusingSpring Security’s content negotiation strategy.
  • 26. Question 10 Spring Boot Interview Questions www.edureka.co WhatisSpringBootdependency management?
  • 27. Question 10 Spring Boot Interview Questions www.edureka.co WhatisSpringBootdependency management? Spring Boot dependency management isusedtomanage dependenciesandconfigurationautomaticallywithoutyouspecifyingthe versionforanyofthatdependencies.
  • 28. Question 11 Spring Boot Interview Questions www.edureka.co Mentiontheminimum requirementsforaSpringboot System
  • 29. Question 11 Spring Boot Interview Questions www.edureka.co Mentiontheminimum requirementsforaSpringboot System Spring Boot 2.1.7.Release requires ✓ Java8+ ✓ SpringFramework5.1.9+ Explicit Build Support ✓ Maven3.3+ ✓ Gradle4.4+ Servlet Container Support ✓ Tomcat9.0–ServletVersion4.0 ✓ Jetty9.4– ServletVersion3.1 ✓ Undertow2.0–Servlet Version4.0
  • 30. Question 12 Spring Boot Interview Questions www.edureka.co Whatisthymeleafandhowtouse thymeleaf?
  • 31. Question 12 Spring Boot Interview Questions www.edureka.co Thymeleaf is a server-side Java template engine used forwebapplications. Itaims to bringnaturaltemplatefor yourwebapplication andcan integrate well with Spring Framework and HTML5 Java web applications. Whatisthymeleafandhowtouse thymeleaf? <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter- thymeleaf</artifactId> </dependency>
  • 32. Question 13 Spring Boot Interview Questions www.edureka.co Canwechangetheportof embeddedTomcatserverinSpring Boot?
  • 33. Question 13 Spring Boot Interview Questions www.edureka.co Canwechangetheportof embeddedTomcatserverinSpring Boot? Yes,wecanchangetheportoftheembeddedtomcatserverbyusing theapplication properties file. Inthisfile,youhavetoaddapropertyof“server.port”andassignitto anyportyouwishto. Forexample,ifyouwanttoassignitto8081,thenyouhavetomention server.port=8081 Onceyoumentiontheportnumber,theapplicationpropertiesfilewill beautomaticallyloadedbySpringBootandtherequired configurationswillbeappliedontotheapplication.
  • 34. Question 14 Spring Boot Interview Questions www.edureka.co WhatistheneedforSpringBoot DevTools?
  • 35. Question 14 Spring Boot Interview Questions www.edureka.co Spring Boot Dev Tools isanelaboratedsetoftools andaimstomaketheprocessofdevelopinganapplicationeasier. Iftheapplicationrunsintheproduction,thenthismoduleis automaticallydisabled,repackagingofarchivesarealso excludedbydefault. So,theSpring Boot Developer Tools applies propertiestotherespectivedevelopmentenvironments. WhatistheneedforSpringBoot DevTools?
  • 36. Question 14 Spring Boot Interview Questions www.edureka.co WhatistheneedforSpringBoot DevTools?
  • 37. Question 14 Spring Boot Interview Questions www.edureka.co Spring Boot Dev Tools isanelaboratedsetoftoolsandaims tomaketheprocessofdevelopinganapplicationeasier. Iftheapplicationrunsintheproduction,thenthismoduleisautomatically disabled,repackagingofarchivesarealsoexcludedbydefault. WhatistheneedforSpringBoot DevTools? <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter- thymeleaf</artifactId> </dependency>
  • 38.
  • 39. Question 15 Spring Boot Interview Questions www.edureka.co Mentionthestepstocreatea SpringBootprojectusing Spring Initializer
  • 40. Question 15 Spring Boot Interview Questions www.edureka.co Spring Initializer isawebtoolprovidedbySpring.Withthe helpofthistool,youcancreateSpringBootprojectsbyjust providingprojectdetails. Mentionthestepstocreatea SpringBootprojectusing Spring Initializer
  • 41. Question 15 Spring Boot Interview Questions www.edureka.co Mentionthestepstocreatea SpringBootprojectusing Spring Initializer ✓ Choose the maven project and the required dependencies. Then, fill the other required details like Group, Artifact, and then click on GenerateProject. ✓ Once the project is downloaded, extract the project on to your system ✓ Next, you have to import this project using the import option on the SpringToolSuiteIDE
  • 42. Question 16 Spring Boot Interview Questions www.edureka.co Mentionthestepstoconnect SpringBootapplicationtoa databaseusingJDBC
  • 43. Question 16 Spring Boot Interview Questions www.edureka.co SpringBootstarterprojectsprovidetherequiredlibrariesto connecttheapplicationwithJDBC. So,forexample,ifyoujusthavetocreateanapplication and connectitwithMYSQLdatabase,youcanfollowthebelowsteps: Mentionthestepstoconnect SpringBootapplicationtoa databaseusingJDBC Step 1: Create a database in MySQL CREATE DATABASE example; Step 2: Create a table inside this database CREATE TABLE customers(customerid INT PRIMARY KEY NOT NULL AUTO_INCREMENT, customername VARCHAR(255));
  • 44. Question 16 Spring Boot Interview Questions www.edureka.co Mentionthestepstoconnect SpringBootapplicationtoa databaseusingJDBC Step 3: Create a Spring Boot project and provide the required details Step 4: Add JDBC, MySQL and web dependencies. spring.datasource.url=jdbc:mysql://localhost:3306/e xample spring.datasource.username=root spring.datasource.password=mysql spring.jpa.hibernate.ddl-auto=create-drop Step 5: Once the project is created, you have to configure the database into application properties.
  • 45. Question 16 Spring Boot Interview Questions www.edureka.co Mentionthestepstoconnect SpringBootapplicationtoa databaseusingJDBC Step 6: The main application.java class should have the following code: package com.edureka; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootAp plication; @SpringBootApplication public class SampleApplication { public static void main(String[] args) { SpringApplication.run(SampleApplication.class, args); } }
  • 46. Question 16 Spring Boot Interview Questions www.edureka.co Mentionthestepstoconnect SpringBootapplicationtoa databaseusingJDBC Step 7: You have to create a controller to handle the HTTP requests, by mentioning the following code: package com.edureka; Import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.web.bind.annotation.RestController; @RestController public class JdbcController { @Autowired JdbcTemplate jdbc; @RequestMapping("/insert") public String index(){ jdbc.execute("insert into customers(name)values('Aryya')"); return "Data Entry Successful"; } }
  • 47. Question 16 Spring Boot Interview Questions www.edureka.co Mentionthestepstoconnect SpringBootapplicationtoa databaseusingJDBC Step 8: Finally execute this project as a Java application. Step 9: Open the URL (localhost:8080/insert), and you will see the output as data entry successful. You can also go forward and check if the data is entered into the table.
  • 48. Question 17 Spring Boot Interview Questions www.edureka.co HowtoenableHTTP/2supportin SpringBoot
  • 49. Question 17 Spring Boot Interview Questions www.edureka.co HowtoenableHTTP/2supportin SpringBoot YoucanenabletheHTTP/2supportinSpringBootby: server.http2.enabled=true
  • 50. Question 18 Spring Boot Interview Questions www.edureka.co Whatarethe @RequestMapping and @RestControllerannotationin SpringBootusedfor?
  • 51. Question 18 Spring Boot Interview Questions www.edureka.co Whatarethe @RequestMapping and @RestControllerannotationin SpringBootusedfor? ✓ Thisannotationisusedtoprovidetheroutinginformationandtellsto SpringthatanyHTTPrequestmustbemappedtotherespective method. ✓ Tousethisannotation,youhavetoimport org.springframework.web.bind.annotation.RequestMapping; @RequestMapping@RequestMapping ✓ Thisannotationisusedtoprovidetheroutinginformationandtellsto SpringthatanyHTTPrequestmustbemappedtotherespective method. ✓ Tousethisannotation, youhavetoimport org.springframework.web.bind.annotation.RequestMapping; @RestController@RestController
  • 52. Question 18 Spring Boot Interview Questions www.edureka.co Whatarethe @RequestMapping and @RestControllerannotationin SpringBootusedfor? package com.edureka; import org.springframework.web.bind.annotation.RequestMapp ing; import org.springframework.web.bind.annotation.RestControl ler; @RestController public class SampleController { @RequestMapping("/example") public String example(){ return"Welcome To Edureka"; } } Consideryouhaveamethodexample()whichshouldmapwith/exampleURL.
  • 53. Question 19 Spring Boot Interview Questions www.edureka.co WhatisSpringBootCLIandhowto executetheSpringBootproject usingbootCLI?
  • 54. Question 19 Spring Boot Interview Questions www.edureka.co SpringBootCLIisatoolsupportedbytheofficial SpringFramework.The stepstoexecuteaSpringBootprojectareasfollows: ➢ DownloadtheCLItoolfromtheofficialsiteandextractthezipfile.The binfolderpresentintheSpringsetupisusedtoexecutetheSpring Bootapplication. ➢ SinceSpringBootCLIexecutesgroovyfiles,youneedtocreatea groovyfileforSpringBootapplication.So,todothat,openterminaland changethecurrentdirectorytobinfolder. WhatisSpringBootCLIandhowto executetheSpringBootproject usingbootCLI?
  • 55. Question 19 Spring Boot Interview Questions www.edureka.co Createacontrollerasfollows: WhatisSpringBootCLIandhowto executetheSpringBootproject usingbootCLI? @RestController public class Sample { @RequestMapping("/example") String index(){ <h1>"Welcome To Edureka"</h1>; } } Executethegroovyfilebymentioning ./spring run Sample.groovy;
  • 56. Question 20 Spring Boot Interview Questions www.edureka.co Whatarethedifferencesbetween JPAandHibernate?
  • 57. Question 20 Spring Boot Interview Questions www.edureka.co Whatarethedifferencesbetween JPAandHibernate? JPAisaDataAccessAbstractionusedtoreducetheamountofboilerplate code JPAJPA HibernateisanimplementationofJavaPersistenceAPIandoffers benefitsofloosecoupling HibernateHibernate V/S
  • 59. Question 21 Spring Boot Interview Questions www.edureka.co TocreateacustomendpointinSpringBoot2.x,youcanusethe @Endpoint annotation. SpringBootalsoexposesendpointsusing@WebEndpointor, @WebEndpointExtensionoverHTTPwiththehelp ofSpringMVC,Jerseyetc. Howcanwecreateacustom endpointinSpringBootActuator?
  • 61. Question 22 Spring Boot Interview Questions www.edureka.co Spring Data aimstomakeiteasyforthedeveloperstouse relationalandnon-relationaldatabases,cloud-baseddataservices, andotherdataaccesstechnologies. So,basically,itmakesiteasyfordataaccessandstillretainsthe underlyingdata. WhatdoyouunderstandbySpring Data?
  • 63. Question 23 Spring Boot Interview Questions www.edureka.co Auto-configuration isusedtoautomaticallyconfigurethe requiredconfigurationfortheapplication. Forexample,ifyouhaveadatasourcebeanpresentintheclasspathof theapplication,thenitautomaticallyconfigurestheJDBCtemplate. Withthehelpofauto-configuration,youcancreateaJavaapplication inaneasyway,asitautomaticallyconfigurestherequiredbeans, controllers,etc. Whatdoyouunderstandbyauto- configurationinSpringBootand howtodisablethe auto- configuration
  • 64. Question 23 Spring Boot Interview Questions www.edureka.co Todisabletheauto-configuration property,youhaveto excludeattributeof @EnableAutoConfiguration,inthe scenariowhereyoudonotwantittobeapplied. Whatdoyouunderstandbyauto- configurationinSpringBootand howtodisablethe auto- configuration @EnableAutoConfiguration(exclude={DataSourceAutoConfig uration.class}) Iftheclassisnotontheclasspath,thentoexcludetheauto- configuration,youhavetomentionthefollowingcode: @EnableAutoConfiguration(excludeName={Sample.class})
  • 65. Question 23 Spring Boot Interview Questions www.edureka.co Whatdoyouunderstandbyauto- configurationinSpringBootand howtodisablethe auto- configuration Apartfromthis,SpringBootalsoprovidesthefacilitytoexcludelistof auto-configurationclassesbyusingthespring.autoconfigure.exclude property.Youcangoforward,andadditeitherintothe application.properties oraddmultipleclasseswithcomma-separated.
  • 67. Question 24 Spring Boot Interview Questions www.edureka.co Whatarethedifferencesbetween @SpringBootApplication and @EnableAutoConfiguration annotation? ✓ Usedinthemainclassorbootstrapclass ✓ Itisacombinationof@Configuration,@ComponentScan and @EnableAutoConfiguration annotations. @SpringBootApplication@SpringBootApplication ✓ Usedtoenableauto-configuration andcomponentscanninginyour project ✓ Itisacombinationof@Configurationand@ComponentScan annotations @EnableAutoConfiguration@EnableAutoConfiguration V/S
  • 69. Question 25 Spring Boot Interview Questions www.edureka.co ✓ TodeployaSpringBootwebapplication,youjusthavetoaddthe followingplugininthepom.xmlfilein,justaddapluginelement topom.xml: @SpringBootApplication@SpringBootApplication WhatarethestepstodeploySpring BootwebapplicationsasJARand WARfiles? @<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin>
  • 70. Question 25 Spring Boot Interview Questions www.edureka.co ✓ Thepackagingelementinthepom.xmlfilemustbesettojartobuilda JARfileasbelow: @SpringBootApplication@SpringBootApplication WhatarethestepstodeploySpring BootwebapplicationsasJARand WARfiles? <packaging>jar</packaging> <packaging>war</packaging>
  • 72. Question 26 Spring Boot Interview Questions www.edureka.co Considerascenario,whereyouhavetoreaddatafromthedatabase. Forexample,letussayyouhaveacustomerdatabase,andyouwantto readthecustomerdetailssuchascustomerID,customername,and customeremailID. Todothat,youwillsetread-onlyonthetransactionaswedonotwantto checkforthechangesintheentities. Canyougiveanexamplefor ReadOnlyastrueinTransaction management?
  • 74. Spring Boot Interview Questions www.edureka.co TodeployadifferentserverwithSpringBoot,followthebelowsteps: Canyouexplainhowtodeploytoa different serverwithSpringBoot? Question 27 01 GenerateaWARfromtheproject 02 DeploytheWARfileontoyourfavouriteserver Question 27
  • 76. Spring Boot Interview Questions www.edureka.co OnewaytoexposethecustomapplicationconfigurationinSpringBootis byusingthe@Value annotation. But,theonlyproblemwiththisannotationisthatalltheconfiguration valueswillbedistributedthroughouttheapplication. Instead,youcanuseacentralized approach. Bycentralizedapproach,Imeanthatyoucandefineaconfiguration componentusingthe@ConfigurationProperties asfollows: Question 28 Whatisthebestwaytoexpose customapplicationconfiguration withSpringBoot? <packaging>@Component @ConfigurationProperties("example") public class SampleConfiguration { private int num; private boolean value; private String msg;</packaging>
  • 77. Spring Boot Interview Questions www.edureka.co Accordingtotheabovesnippet,thevaluesconfiguredin application.properties willbeasfollows: Question 28 Whatisthebestwaytoexpose customapplicationconfiguration withSpringBoot? example.num: 100 example.value: true example.msg: Dynamic Message
  • 79. Spring Boot Interview Questions www.edureka.co Question 29 Canwecreateanon-web applicationinSpringBoot? Yes,wecancreate a non-web applicationbyremovingthe webdependenciesfromclasspathalongwithchangingthewaySpring Boot creates the application context.
  • 80.
  • 82. Spring Boot Interview Questions www.edureka.co Question 30 Toconnectanexternaldatabase,youhavetofollowthebelowsteps: ➢ StartbyaddingthedependencyforMySQLConnectortopom.xml ➢ ThenremoveH2Dependencyfrompom.xml ➢ Now,setupyourMySQLdatabaseandconfigureyourconnectiontothe MySQLdatabase ➢ Restartyourproject Whatarethestepstoconnectan externaldatabaselikeMySQLor Oracle?
  • 84. Spring Boot Interview Questions www.edureka.co Question 31 TheadvantagesoftheYAMLfilethanapropertiesfileisthatthedatais storedinahierarchicalformat. So,itbecomesveryeasyforthedeveloperstodebugifthereisanissue. TheSpringApplicationclasssupportstheYAMLfileasanalternative to propertieswheneveryouusetheSnakeYAMLlibraryonyourclasspath. The different ways to load a YAML file in Spring Boot is as follows: ➢ UseYamlMapFactoryBeantoloadYAMLasaMap ➢ UseYamlPropertiesFactoryBean toloadYAMLasProperties MentiontheadvantagesofYAML filethanPropertiesfileandthe different waystoloadYAMLfilein Springboot
  • 86. Spring Boot Interview Questions www.edureka.co Question 32 WhenweusetheSpring Boot Auto Configuration, automaticallythespring-boot-starter-data- jpadependencygetsaddedtothepom.xmlfile. Now,sincethisdependencyhasatransitivedependencyonJPAand Hibernate,Spring Boot automatically auto- configures Hibernate as the default implementation for JPA,wheneveritseesHibernatein theclasspath. HowisHibernatechosenasthe defaultimplementationforJPA withoutanyconfiguration?
  • 88. Spring Boot Interview Questions www.edureka.co Question 33 Spring Data REST isusedtoexposetheRESTfulresources aroundSpringDatarepositories. Considerthefollowingexample: WhatdoyouunderstandbySpring DataREST? @RepositoryRestResource(collectionResourceRel = "sample", path = "sample") public interface SampleRepository extends CustomerRepository<sample, Long> {
  • 89. Spring Boot Interview Questions www.edureka.co Question 33 WhatdoyouunderstandbySpring DataREST? ToexposetheRESTservices,youcanusethePOSTmethodinthe followingway: { "customerid": "Rohit", "customeremailid": "customer1@abc.com" } ResponseContent: { "customerid": "Rohit", "customeremailid": "customer1@abc.com", "_links": { "self": { "href": "http://localhost:8080/sample/1" }, "sample": { "href": "http://localhost:8080/sample/1" }}
  • 91. Spring Boot Interview Questions www.edureka.co Question 34 The@GetMappingisacomposedannotationthatactsasashortcut for@RequestMapping(method =RequestMethod.GET). Boththesemethodssupporttheconsumes.Theconsumeoptionsare: consumes=“text/plain” consumes={“text/plain”,“application/*”} Whatisthedifferencebetween RequestMappingandGetMapping?
  • 93. Spring Boot Interview Questions www.edureka.co Question 35 Theboundary of the transaction shouldstartfromthe ServiceLayersincethelogicforthebusinesstransactionispresentin thislayeritself. Inwhichlayer,shouldtheboundary ofatransactionstart?
  • 95. Spring Boot Interview Questions www.edureka.co Question 36 Howdoespath=”sample”, collectionResourceRel=”sample” workwithSpringDataRest? @RepositoryRestResource(collectionResourceRel = "sample", path = "sample") public interface SampleRepository extends PagingAndSortingRepository<Sample, Long> ➢ path – This section is used to mention the segment under whichtheresourceistobeexported. ➢ collectionResourceRel – This value is used to generatelinkstothecollectionresource.
  • 96. Question 37 Spring Boot Interview Questions www.edureka.co Explainhowtoregisteracustom auto-configuration.
  • 97. Spring Boot Interview Questions www.edureka.co Question 37 Explainhowtoregisteracustom auto-configuration. Inordertoregisteranauto-configurationclass,youhavetomention the fully-qualified name underthe @EnableAutoConfiguration key META- INF/spring. factories file. Also,ifwebuildthewithmaven,thenthisfileshouldbeplacedinthe resources/META-INT directory.
  • 98. Question 38 Spring Boot Interview Questions www.edureka.co HowdoyouConfigureLog4jfor logging?
  • 99. Spring Boot Interview Questions www.edureka.co Question 38 SinceSpringBootsupports Log4j2 for logging a configuration,youhavetoexclude Logback and include Log4j2 for logging.Thiscanbeonlydoneifyouare usingthestartersproject. HowdoyouConfigureLog4jfor logging?
  • 100. Question 39 Spring Boot Interview Questions www.edureka.co Mentionthedifferencesbetween WARandembeddedcontainers
  • 101. Spring Boot Interview Questions www.edureka.co Question 39 HowdoyouConfigureLog4jfor logging? WARbenefitsaconsiderablemeasurefromSpringBoot WARWAR OnlyonecomponentofSpringBootandisutilizedduringimprovements EmbeddedContainersEmbeddedContainers V/S
  • 102. Question 40 Spring Boot Interview Questions www.edureka.co Whatdoyouthinkistheneedfor Profiles?
  • 103. Spring Boot Interview Questions www.edureka.co Question 40 ProfilesinSpringprovidesawaytosegregatethepartsofthe applicationconfigurationandmakesitavailableinenvironments.So, basically,any@Component or a @Configuration can bemarkedwitha@Profiletolimitasitisloaded. Whatdoyouthinkistheneedfor Profiles?
  • 104. Question 41 Spring Boot Interview Questions www.edureka.co Whatdoyouthinkistheneedfor Profiles?
  • 105. Spring Boot Interview Questions www.edureka.co Question 41 ThestepstoaddacustomJScodewithSpringBootareas follows: ✓ Createafoldercalledstaticundertheresourcesfolder ✓ Inthisfolder,youcanputthestaticcontentinthatfolder Whatarethestepstoaddacustom JScodewithSpringBoot? Note:Justincase,thebrowserthrowsanunauthorizederror,youeither disablethesecurityorsearchforthepasswordinthelogfile,andeventually passitintherequestheader.
  • 106. Question 42 Spring Boot Interview Questions www.edureka.co Howtoinstructanauto- configurationtobackoffwhena beanexists?
  • 107. Spring Boot Interview Questions www.edureka.co Question 42 Toinstructanauto-configuration classtobackoffwhenabean exists,youhavetousethe @ConditionalOnMissingBean annotation. Theattributesofthisannotationareasfollows: ➢ value:Thisattributestoresthetypeofbeanstobechecked ➢ name:Thisattributestoresthenameofbeanstobechecked Howtoinstructanauto- configurationtobackoffwhena beanexists?
  • 108. Question 43 Spring Boot Interview Questions www.edureka.co WhyisSpringDataRESTnot recommendedinreal-world applications?
  • 109. Spring Boot Interview Questions www.edureka.co Question 43 Spring Data REST isnotrecommendedinreal-world applicationsasyouareexposingyourdatabaseentities directly asRESTservices. WhiledesigningRESTfulservices,thetwomostimportantthingsthat weconsideristhedomainmodelandtheconsumers. But,whileusingSpringDataREST,noneoftheseparametersare considered.Theentitiesaredirectlyexposed. UseSpringDataREST,for the initial evolution of the project. WhyisSpringDataRESTnot recommendedinreal-world applications?
  • 110. Question 44 Spring Boot Interview Questions www.edureka.co Whatistheerroryouseeif H2is notintheclasspath?
  • 111. Spring Boot Interview Questions www.edureka.co Question 44 IfH2isnotpresentintheclasspath,thenyouseethefollowing error: Whatistheerroryouseeif H2is notintheclasspath? Cannot determine embedded database driver class for database type NONE
  • 112. Spring Boot Interview Questions www.edureka.co Question 44 Whatistheerroryouseeif H2is notintheclasspath? Toresolvethiserror,addH2tothepom.xmlfile,andrestartyour server. Thefollowingcodesnippetcanbeaddedtoaddthedependency: <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency>
  • 113.
  • 114. Question 45 Spring Boot Interview Questions www.edureka.co Whatisthewaytouseprofilesto configuretheenvironment- specificconfigurationwithSpring Boot?
  • 115. Spring Boot Interview Questions www.edureka.co Question 45 Whatisthewaytouseprofilesto configuretheenvironment- specificconfigurationwithSpring Boot? Since its a known fact that a Profile is nothing but a key to identify an environment lets consider the following two profiles in the example: •dev •Prod Consider the following properties present in the application propertiesfile: example.number: 100 example.value: true example.msg: Dynamic Message
  • 116. Spring Boot Interview Questions www.edureka.co Question 45 Whatisthewaytouseprofilesto configuretheenvironment- specificconfigurationwithSpring Boot? Now, say you want to customize the application.properties for dev profile, then you need to create a file with name application- dev.properties and override the properties that you want to customize. Youcanmentionthefollowingcode: example.msg: Dynamic Message in Dev Similarly,ifyouwanttocustomizetheapplication.properties forprod profile,thenyoucanmentionthefollowingcodesnippet: example.msg: Dynamic Message in Prod
  • 117. Spring Boot Interview Questions www.edureka.co Question 45 Whatisthewaytouseprofilesto configuretheenvironment- specificconfigurationwithSpring Boot? Once you are done with the profile-specific configuration, you havetosettheactive profileinanenvironment. Todothat, either youcan: ✓ Use-Dspring.profiles.active=prod in arguments ✓ Usespring.profiles.active=prodinapplication.propertiesfile
  • 118. Question 46 Spring Boot Interview Questions www.edureka.co Mentionthedependenciesneeded tostartupaJPAApplicationand connecttoin-memorydatabaseH2 withSpringBoot?
  • 119. Spring Boot Interview Questions www.edureka.co Question 46 Mentionthedependenciesneeded tostartupaJPAApplicationand connecttoin-memorydatabaseH2 withSpringBoot? web starter H2 data JPA starter ThedependenciesareneededtostartupaJPAApplicationandconnect toin-memorydatabaseH2withSpringBoot
  • 120. Spring Boot Interview Questions www.edureka.co Question 46 Mentionthedependenciesneeded tostartupaJPAApplicationand connecttoin-memorydatabaseH2 withSpringBoot? <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data- jpa</artifactId> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency>
  • 121. Question 47 Spring Boot Interview Questions www.edureka.co WhatdoyouunderstandbySpring Bootsupportsrelaxedbinding?
  • 122. Spring Boot Interview Questions www.edureka.co Question 47 WhatdoyouunderstandbySpring Bootsupportsrelaxedbinding? Relaxed binding,isawayinwhich,thepropertynamedoesnot needtomatchthekeyoftheenvironmentproperty. InSpringBoot,relaxedbindingisapplicabletothetype-safebindingof theconfigurationproperties.
  • 123. Spring Boot Interview Questions www.edureka.co Question 47 WhatdoyouunderstandbySpring Bootsupportsrelaxedbinding? Forexample,ifapropertyinabeanclasswiththe @ConfigurationProperties annotationisused sampleProp,thenitcanbeboundedtoanyofthefollowingenvironment properties: ❑sampleProp ❑sample_Prop ❑sample_Prop ❑SAMPLE_PROP
  • 124. Question 48 Spring Boot Interview Questions www.edureka.co Whereisthedatabaseconnection informationspecifiedandhowdoes itautomaticallyconnecttoH2?
  • 125. Spring Boot Interview Questions www.edureka.co Question 48 Whereisthedatabaseconnection informationspecifiedandhowdoes itautomaticallyconnecttoH2? ItisbecauseoftheSpring Boot Autoconfiguration that,configuresthedependenciesoftheapplication. So,thedatabaseconnection information,andautomaticallyconnecting thedatabasetoH2isdonebytheauto-configurationproperty.
  • 126. Question 49 Spring Boot Interview Questions www.edureka.co WhatisthenameofthedefaultH2 databaseconfiguredbySpring Boot?
  • 127. Spring Boot Interview Questions www.edureka.co Question 49 WhatisthenameofthedefaultH2 databaseconfiguredbySpring Boot? ThenameofthedefaultH2databaseistestdb spring.datasource.name=testdb # Name of the datasource. Note:Justin-caseifyouareusingH2in-memorydatabase,thenexactly thatisthenameofSpringBootwhichisusedtosetupyourH2database.
  • 128. Question 50 Spring Boot Interview Questions www.edureka.co Doyouthink,youcanusejetty insteadoftomcatinspring-boot- starter-web?
  • 129. Spring Boot Interview Questions www.edureka.co Question 50 Yes,wecanusejettyinsteadoftomcatinspring-boot-starter-web,by removingtheexistingdependencyandincludingthefollowing: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter- tomcat</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter- jetty</artifactId> </dependency> Doyouthink,youcanusejetty insteadoftomcatinspring-boot- starter-web?